I recently was trying to swap some SSD drives between laptops and still keep the same OSes on the respective machines, which involved some backup and disk cloning. That wasn't difficult, it was the point when I couldn't leave well enough alone, I saw one of the SSD drives with ~ 500MB of a FAT32 partition that was unused, so I figured I could move around some partitions using a partition editor to shuffle up the hidden partitions, and expand the main OS partition. Well that was well and good until I tried slightly extending the EFI partition, and that broke a lot of stuff. Then I realized the hard way that the EFI partition is a special partition that can't be cloned to from another disk image that has a good EFI partition. (I didn't wan't to clone the entire drive again because there was more work I did on the new system that wasn't on the backup, silly me).
Thankfully, digging around the interwebs, I was able to find some resources from a few sites about EFI partitions and how to unfubar oneself. (Credits and links to the original sites below):
Per Wikipedia: https://en.wikipedia.org/wiki/EFI_system_partition:
"The EFI (Extensible Firmware Interface) system partition or ESP is a partition on a data storage device (usually a hard disk drive or solid-state drive) that is used by computers adhering to the Unified Extensible Firmware Interface (UEFI)."
EFI should really be renamed Eventually Fubared Instantly.
If the EFI partition ever gets nuked, wrecked, or just plain fubar, consider running through these steps:
To Delete the EFI System Partition in Windows 10:
1. If you can't boot the system perform step 1a, then go to step 2. If you can boot the system, skip step 1a and continue with step 1b:.
1a. Boot using a Windows 10 USB Key, selecting Repair; Go to Advanced Tools and select a Command Prompt.
1b. On the Start menu find and run the Command Prompt as Administrator
2. Run DISKPART, the Windows Disk Partition Tool
C:\> diskpart
On the DISKPART> prompt, go through the following steps:
3. List the disks that are detected:
DISKPART> list disk
4. After identifying the main disk containing the EFI partition (or where it used to be) select it:
DISKPART> select disk 1
5.List the disk partitions to identify which partition the EFI partition was or the partition you would like it to be:
DISKPART> list part
6. Select the partition:
DISKPART> select part 1
7. Delete the partition:
DISKPART> delete part
To Create the EFI System Partition in Windows 10:
1. If you can't boot the system perform step 1a, then go to step 2. If you can boot the system, skip step 1a and continue with step 1b:.
1a. Boot using a Windows 10 USB Key, selecting Repair; Go to Advanced Tools and select a Command Prompt.
1b. On the Start menu find and run the Command Prompt as Administrator
2. Run DISKPART, the Windows Disk Partition Tool
On the DISKPART> prompt, go through the following steps:
3. List the disks that are detected:
DISKPART> list disk
4. After identifying the main disk containing the EFI partition (or where it used to be) select it:
DISKPART> select disk 1
5.List the disk partitions to identify which partition the EFI partition was or the partition you would like it to be:
DISKPART> list part
6. Select the partition:
DISKPART> select part 1
7. Create the partition:
DISKPART> create partition efi
8. Format the partition to FAT32:
DISKPART> format quick fs=fat32
9. Identify the volume where the Windows OS is installed (i.e. C:\WINDOWS). Note the drive letter here may be different than C, this may be temporary:
DISKPART> list volume
10. Exit Diskpart and run the tool to copy the needed files to the EFT partition, noting the drive letter where Windows was installed on Step 9 above: (Replace the D below with the proper drive letter):
C:\> bcdboot D:\windows
11: Close out the command prompt and reboot the system, you should be good to go!
Credit to AnyRecover for their original instructions:
https://www.anyrecover.com/hard-drive-recovery-data/how-to-create-and-delete-efi-system-partition-in-windows/#tip1
Thursday, October 24, 2019
Tuesday, September 17, 2019
Testing Gzipped Tarball in Bash
Originally sourced from stack exchange. modified a bit:
https://unix.stackexchange.com/questions/129599/test-tar-file-integrity-in-bash
Modified from the source link above, the following command will iteratively test each .tgz file within the current directory for errors, and if any are detected, will report an error.
$ for i in *.tgz; do echo "Testing $i..."; if tar xOfz $i &> /dev/null; then echo "Error with tarball $i"; fi; done
Options used:
x - Extract from archive
O - Write output to standard out instead of disk
f - Read input from a file
z - Tarball is compressed with Gzip (Some OSes may automatically detect Gzip and not need this option)
&> /dev/null - Redirect both stdout and stderr to /dev/null
https://unix.stackexchange.com/questions/129599/test-tar-file-integrity-in-bash
Modified from the source link above, the following command will iteratively test each .tgz file within the current directory for errors, and if any are detected, will report an error.
$ for i in *.tgz; do echo "Testing $i..."; if tar xOfz $i &> /dev/null; then echo "Error with tarball $i"; fi; done
Options used:
x - Extract from archive
O - Write output to standard out instead of disk
f - Read input from a file
z - Tarball is compressed with Gzip (Some OSes may automatically detect Gzip and not need this option)
&> /dev/null - Redirect both stdout and stderr to /dev/null
Misc. Linux Sysadmin tips
Got around to updating the home office machines, and thought it would be a good idea to keep some recurring tips handy:
Disabling SSH login for root user
Disabling SSH login for root user
- Edit /etc/ssh/sshd_config
- Set PermitRootLogin to no (Remove # if present)
- Add AllowUsers
- Save, then restart sshd:
$ service sshd restart
Setup Passwordless SSH:
- Create SSH keypair with options, such as:
$ ssh-keygen -b 5120 - chmod created keypair:
$ chmod 600 - SCP the public key to target machine.
- On target machine:
$ mkdir ~/.ssh$ chmod 700 ~/.ssh - If ~/.ssh/authorized_keys doesn't exist:
move the public key from home folder to ~/.ssh/authorized_keys then
$ chmod 600 ~/.ssh/authorized_keys - If it does exist, then append the public key to the authorized_keys:
$ cat>> ~/.ssh/authorized_keys , then delete the public key. - Test by SSHing to the target machine
Editing Hostnames
- Edit /etc/sysconfig/network. modify HOSTNAME= to FQDN
- Edit /etc/hosts. Add IP address with FQDN and shortname
- Restart network services:
$ /etc/init.d/network restart
Subscribe to:
Posts (Atom)