Linux filesystem
disk suage
# show disk usage
ncdu
# show disk usage
du -sch
symbolic links vs. hard links
symbolic links (/soft links/symlinks) and hard links
# soft link (symlink)
ln -s source.file link.file
# hard link
ln source.file link.file
hierarchy
- disk
- physical volume
- volume group
- logical volume
- filesystem / mount point
mount a logical vol
- create logical volume on volume group
- check where it is created under /dev/
- formate the logical volume
- mount volume (can be anyhere is not restricted to root / level of filesystem)
- (optional) add mount to fstab file so it will recreated at startup
# 1.
sudo lvcreate -L 100G -n <new logical volume> <volume group>
# 2.
sudo lvscan
# 3. path can be found via step 2
sudo mkfs.ext4 /dev/<volume group>/<logical volume>
#4
sudo mount /dev/<volume group>/<logical volume> /<directory_which_exists>
extend a logical volume
- check how much space is left on volume group
- check where the loigcal volume is located under /dev/ (not /dev/mapping but the real path)
- extend logical volume
- check if successful
# 1.
vgs
# 2.
lvscan
# 3. path can be found via step 2
# -L50G is target size 50 GB
lvextend -L50G /dev/<volume group>/<logical volume>
# 4.
lvscan
fstab
/etc/fstab is responsible for mounting volumes on startup.
- always create a backup :
sudo cp /etc/fstab /etc/fstab.backup
- before restarting check if fstab is ok. If there are no returned messages everything is okay:
sudo mount -a
mount
- a mount point is just a or folder/directory (e.g. mkdir -p /data )
- you do not need to use the /mnt directory. It is just a convention to use it if you do not have a specific directory to mount
- you can mount formatted devices under /dev to any mountpoint
- to make a mount persistant after restart you need to add it to /etc/fstab
List stuff
df -h
du -g
# list physical volumes
pvs
# list volume groups
vgs
# list logical volume
lvs