Eureka Moment Wiki

One eureka moment at the time

User Tools

Site Tools


linux:shell_commands:fdisk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
linux:shell_commands:fdisk [2018/06/20 10:27]
tplecko
linux:shell_commands:fdisk [2018/06/20 10:30] (current)
tplecko
Line 1: Line 1:
 ====== Create partitions using CLI on linux ====== ====== Create partitions using CLI on linux ======
 First and foremost: First and foremost:
 +
 **!! WARNING !!** **!! WARNING !!**
  
Line 7: Line 8:
 To quickly set up a drive up as a single ext4 partition... To quickly set up a drive up as a single ext4 partition...
 View detected devices of class "​DISK"​ View detected devices of class "​DISK"​
-<​code ​bash>lshw -C disk</​code>​ +<​code ​shell>lshw -C disk</​code>​ 
- +View existing partition table(s) 
-    ​View existing partition table(s) +<code shell>fdisk -l</​code>​ 
- +Edit the partition table for my chosen device (in this case, "​sdx"​) 
-    ​fdisk -l +<code shell>fdisk /dev/sdx</​code>​ 
- +Within FDISK, press: 
-    ​Edit the partition table for my chosen device (in this case, "​sdx"​) +<​code>​ 
- +d ...to delete the current partition 
-    ​fdisk /dev/sdx +n ...to create a new partition 
- +p ...to specify it as a PRIMARY partition 
-    ​Within FDISK, press: +1 ...to set it as the 1ST primary partition 
- +w ...to write the changes. 
-        d ...to delete the current partition +</​code>​ 
- +Display the new partition table: 
-        ​n ...to create a new partition +<code shell>fdisk -l</​code>​ 
- +Format the new partition'​s filesystem as type ext4 
-        ​p ...to specify it as a PRIMARY partition +<code shell>mkfs -t ext4 /dev/sdx1</​code>​ 
- +Create a new directory where the new drive will mount into: 
-        ​1 ...to set it as the 1ST primary partition +<code shell> 
- +mkdir /storage 
-        ​w ...to write the changes. +mount /dev/sdx1 /storage 
- +</​code>​
-    Display the new partition table: +
- +
-    ​fdisk -l +
- +
-    ​Format the new partition'​s filesystem as type ext4 +
- +
-    ​mkfs -t ext4 /dev/sdx1 +
- +
-    ​Create a new directory where the new drive will mount into: +
- +
-    mkdir /storage +
-    mount /dev/sdx1 /storage+
  
 TUNING TUNING
- +Remove reserved blocks (i.e. set to 0%), since this drive is just for user data 
-    ​Remove reserved blocks (i.e. set to 0%), since this drive is just for user data +<code shell>tune2fs -m 0 /dev/sdx1</​code>​ 
- +Since server is on UPS, Set write-back so apps don't wait for actual disk writes 
-    ​tune2fs -m 0 /dev/sdx1 +<code shell>tune2fs -o journal_data_writeback /dev/sdx1</​code>​ 
- +Mount at boot up using /etc/fstab and also set write-back policy 
-    ​Since server is on UPS, Set write-back so apps don't wait for actual disk writes +<code shell>vi /etc/fstab</​code>​ 
- +Find (or add) the relevant line in fstab for your drive. Parameters in fstab are separated by white space, for example the drive described above might appear as: 
-    ​tune2fs -o journal_data_writeback /dev/sdx1 +<code shell>/dev/sdx1 /storage ext4 relatime,​errors=remount-ro 0 1</​code>​ 
- +  ​* ​The first parameter identifies the partition (either by /dev/ or a long UUID); 
-    ​Mount at boot up using /etc/fstab and also set write-back policy +  ​* ​The second parameter is the path the partition will be mounted to; 
- +  ​* ​Third is the filesystem type; 
-    ​vi /​etc/​fstab +  ​* ​The fourth parameter contains the options; 
- +  ​* ​Fifth is the dump schedule for backups; and, 
-    ​Find (or add) the relevant line in fstab for your drive. Parameters in fstab are separated by white space, for example the drive described above might appear as: +  ​* ​The sixth parameter is pass-number (used to control fsck order).
- +
-    ​/dev/sdx1 /storage ext4 relatime,​errors=remount-ro 0 1 +
- +
-        ​The first parameter identifies the partition (either by /dev/ or a long UUID); +
-        The second parameter is the path the partition will be mounted to; +
-        Third is the filesystem type; +
-        The fourth parameter contains the options; +
-        Fifth is the dump schedule for backups; and, +
-        The sixth parameter is pass-number (used to control fsck order). +
 Change the options (4th parameter) to: Change the options (4th parameter) to:
- +<code shell>noatime,​nodiratime,​data=writeback,​barrier=0,​nobh,​errors=remount-ro</​code>​
-noatime,​nodiratime,​data=writeback,​barrier=0,​nobh,​errors=remount-ro +
 Reboot to check that everything went well. Reboot to check that everything went well.
 Remember these commands are destructive! Have backups and be careful! Remember these commands are destructive! Have backups and be careful!
  
linux/shell_commands/fdisk.txt · Last modified: 2018/06/20 10:30 by tplecko