Hard Drives
- SCSI and SATA Drives are mounted at
/dev/sda0.a= Device,0= Partition. - NVMe Drives ar mounted at
/dev/nvme0n1p1. Numbers stand for Controller, Device, Partition. - Use GPT not MBR
File Systems
- XFS
- Can only be extended not shrinked
- No file size limit
- Ext4
- Can be extended and shrinked
Show available drives and partitions
lsblk
Create partition (parted)
parted
? // print help
select /dev/sdb
print // print device info
mklabel gpt
mkpart
// Name e.g. home
// Type xfs
// Start e.g. 1
// End e.g. 1g or 1000MiB
Tell Kernel about new Partition
partprobe
Generate UUIDs
udevadm settle
blkid
Create partition (gdisk)
gdisk -l /dev/sdb
? // print help
o // create GPT
p // print partition table
n // new partition
// ENTER for next free sector
// +500M
// 8300 Linux file system
w // write changes to disk
Delete partition (gdisk)
d 1 // delete partition 1
w // write changes
Check changes:
blkid
Tell Kernel about new Partition
partprobe
Format Partition
mkfs.ext4 /dev/sdb1
Mount Partition
mount /dev/sdb1 /mnt
Unmount Partition
umount /mnt
If someone is using the partition list the process:
lsof /mnt/
- Create Testfile
dd if=/dev/random of=test bs=1M count=100
Automount device on boot (fstab)
In /etc/fstab:
<ID> <Mounting Point> <Format> <Options> <Dump> <Pass>
/dev/sda1 /mnt/hdd0 xfs defaults 0 0
UUID=9382-34... /mnt/hdd1 xfs defaults 0 0
Test if it worked:
mount -a
Inform systemd about the changes:
systemctl daemon-reload
Automount device on boot (systemd)
In /etc/systemd/system/hdd0.mount write:
[Unit]
Description=MountHdd0
[Mount]
Where=/mount/hdd0
What=/dev/disk/by-uuid/3fd2123-...
Type=ext4
Options=defaults
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
Try out:
systemctl start hdd0.mount
Load on boot:
systemctl enable hdd0.mount
systemctl list-unit-files -t mount
AutoFS
sudo apt install autofs
systemctl enable --now autofs
In /etc/auto.master add:
XFSDump and XFSRestore
xfsdump -l 0 -f /root/monday.fullbackup /database
# -l <level> 0 = full backup
- Show which dumps exist:
xfsdump -I
xfsrestore -f /root/monday.fullbackup /database