Command | Description |
---|---|
dd if=/dev/<sdx> bs=<bs> count=1 | hexdump -C hexdump -C -n <bytes> <dev> |
Print hexdump of a drive |
- Set hashed b-trees to speed up lookup for large dirs:
tune2fs -O dir_index /dev/<SDX>
- Optimize directories (reindexing/sorting and compressing):
e2fsck -D /dev/<SDX>
chmod g+s <PATH> # Set gid
setfacl -d -m g::rwx <PATH> # Set default permission for group to rwx
setfacl -d -m o::rx <PATH> # Set default for other
Verify: getfacl <PATH>
-
Reset all data:
dd if=/dev/zero of=/dev/<SDX> bs=4096 status=progress
Calculate block size -
Create new partition:
parted /dev/<SDX> mklabel gpt parted -a opt /dev/<SDX> mkpart primary <PARTITION> 0% 100%
<PARTITION>
- ext4,fat32 -
Format:
mkfs.ext4 /dev/<SDX>
Option Description -m 0
reserved-blocks-percentage -T largefile
usage-type (defined in /etc/mke2fs.conf
)For FAT:
dosfstools
-
Label:
Filesystem Command EXT e2label /dev/<SDX> <LABEL>
FAT fatlabel /dev/<SDX> <LABEL>
- Create swap
fallocate --length 2GiB <SWAPFILE> # Initiate swap chmod 600 <SWAPFILE> # Change permissions mkswap <SWAPFILE> # Define as swap swapon <SWAPFILE> # Activate
- Add to fstab:
<SWAPFILE> swap swap defaults 0 0 >> /etc/fstab
- (Optional) Set swappiness:
vm.swappiness=10
swapoff -a
rm -f <SWAPFILE>
cryptsetup --key-size 512 luksFormat /dev/sdXX /path/to/key
<name> UUID=<UUID> /path/to/key > /etc/crypttab
systemctl daemon-reload && systemctl start systemd-cryptsetup@<name>.service
cryptsetup luksHeaderBackup /dev/sdXX --header-backup-file header.img
gpg2 --recipient <EMAIL> --encrypt header.img
# We need to resize the logical volume to use all the existing and free space of the volume group
$ lvm
lvm> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
lvm> exit
# And then, we need to resize the file system to use the new available space in the logical volume
$ resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 58
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 120784896 (4k) blocks long.