-
Notifications
You must be signed in to change notification settings - Fork 1
/
03-file-system.sh
77 lines (55 loc) · 2.11 KB
/
03-file-system.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# LINKS
ls -i # see items inode values
ln # make links between files
ln file1 file2 # creates hard link
ln -s file1 file2 # creates symbolic link
# DISK USAGE
df # report file system disk space usage
df -h # human readable format
df -i # report inode usage
du # estimate file usage space
du -hsc *
# PARTITIONING
fdisk # change partition table
sudo fdisk -l
dmesg --follow # follow kernel messages to discover attached HDD
lsblk # list information about block devices
sudo fdisk /dev/sdb # then enter:
# 'g' to use GPT partition tables
# 'n' to create partition (use default values to use the whole disk)
# 'w' to save and exit
mkfs # make a Linux filesystem
sudo mkfs.ext4 /dev/sdb1 # format partition using ext4 filesystem
# MOUNT VOLUME
sudo blkid # get UUID of a new device
sudo nano /etc/fstab
# UUID="3f849d0b-fc97-45ea-a0b2-ff0aa466322c" /mnt/docker/ ext4 defaults 0 2
# NCurses Disk Usage
sudo apt install ncdu
sudo ncdu
# LVM - Linux Logical Volume Manager
sudo apt install lvm2
pvs # show physical volumes
pvdisplay # show physical volumes with more details
vgs # show volume groups
vgdisplay # show volume groups with more details
lvs # show logical volumes
lvdisplay # show logical volumes with more details
# extend logical volume
sudo lvextend /dev/ubuntu-vg/ubuntu-lv -l +100%FREE
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
# SWAP FILE
free -m # to verify whether swap exists
sudo fallocate -l 16G /swapfile
sudo mkswap /swapfile
/swapfile none swap sw 0 0 # add this line to /etc/fstab file
sudo swapon -a
sudo swapoff -v /swapfile # deactivates swap file
# ALLOCATE NEW STORAGE SPACE OF EXISTING DISK
# (AFTER EXTENDING ALREADY MOUNTED DISK)
sudo parted -l # fix GPT PMBR size mismatch
sudo fdisk /dev/sdb # create a new partition will remaining unallocated space
sudo pvcreate /dev/sdb2 # create physical volume
sudo vgextend ubuntu-vg /dev/sdb2 # add new physical volume to the existing volume group
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv # extend logical volume (use 100% of additional free space)
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv # resize file system to use new available space in logical volume