# File System

Some notes on working with the linux file system


# Create Swap File

fallocate -l 4G /swap
chmod 600 /swap
mkswap /swap
swapon /swap

/etc/fstab:

/swap swap swap defaults 0 0

# Detect new disk size without reboot

Tested on a VM:

echo 1 >/sys/class/scsi_device/<Disk ID>/device/rescan

You can check in /dev/disk/by-path/ for the correct ID

# Re-Scan SCSI Bus After Adding New Disk

echo "- - -" > /sys/class/scsi_host/hostX/scan

# Full Disk Restore Checklist

For when you're using a backup system that doesn't handle the boot configuration, grub, etc.

# Update fstab

Grab the new UUID of the disks by running blkid
Edit /etc/fstab and replace any /dev/sdX or UUID= entries with the new UUID=xxxxxxx

# Generate new initrd

For Centos 6, run dracut -f
You can also target a specific version of the kernel: dracut -f </boot/filename.img> <kernel.version.x86_64>
Reference here (opens new window)

# Update grub config

Different methods used depending on flavour of linux. For Centos 6, you can just edit /etc/grub.conf
Replace any UUID references with your new ones

# Update network settings

Update the MAC for the network interfaces if this is a different machine. Edit the file at /etc/udev/rules.d/70-persistent-net.rules

# Install grub

For Centos 6, run grub-install

Last Updated: 2023/01/29 17:35+00:00