Skip to content

Instantly share code, notes, and snippets.

@wit543
Created January 23, 2020 07:12
Show Gist options
  • Save wit543/0dd728330164d9a7ae3836bcc6550624 to your computer and use it in GitHub Desktop.
Save wit543/0dd728330164d9a7ae3836bcc6550624 to your computer and use it in GitHub Desktop.
How to add partition and mount
root@v01 /home/w
# fdisk /dev/sda # drive to create partition !770
-----------------------------------------------------------------------------------------------------------------
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
Command (m for help): m
Help:
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): n
Partition number (2-128, default 2):
First sector (2147485696-11721045134, default 2147485696):
Last sector, +sectors or +size{K,M,G,T,P} (2147485696-11721045134, default 11721045134):
Created a new partition 2 of type 'Linux filesystem' and of size 4.5 TiB.
Partition #2 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): w
The partition table has been altered.
Syncing disks.
-----------------------------------------------------------------------------------------------------------------
root@v01 /home/w
# fdisk -l !771
Disk /dev/nvme0n1: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0C16337E-EC20-4C0F-A008-92D16FFB729A
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 999423 997376 487M Linux filesystem
/dev/nvme0n1p2 999424 976771071 975771648 465.3G Linux LVM
Disk /dev/sda: 5.5 TiB, 6001175126016 bytes, 11721045168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: CDEFB4EE-78A9-4FEA-9446-5EEFC797A1A0
Device Start End Sectors Size Type
/dev/sda1 2048 2147485695 2147483648 1T Linux filesystem
/dev/sda2 2147485696 11721045134 9573559439 4.5T Linux filesystem <<<<<<<< New partition
Disk /dev/mapper/ubuntu--vg-root--lv: 342.4 GiB, 367597191168 bytes, 717963264 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-swap--lv: 29.8 GiB, 31998345216 bytes, 62496768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/ubuntu--vg-var--lv: 93.1 GiB, 99996401664 bytes, 195305472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
-----------------------------------------------------------------------------------------------------------------
root@v01 /home/w
# mount /dev/sda2 /data # mount new partition !772
-----------------------------------------------------------------------------------------------------------------
root@v01 /home/w
# vi /etc/fstab # auto mount new partition when start
-----------------------------------------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/ubuntu--vg-root--lv / ext4 errors=remount-ro 0 1
# /boot was on /dev/nvme0n1p1 during installation
UUID=664511d7-04c9-4de8-908b-03d2885802f7 /boot ext4 defaults 0 2
/dev/mapper/ubuntu--vg-var--lv /var ext4 defaults 0 2
/dev/mapper/ubuntu--vg-swap--lv none swap sw 0 0
/dev/sda1 /home2 ext4 defaults 0 0
/dev/sda2 /data ext4 defaults 0 0 # Add new partition to mount
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment