Difference between revisions of "New Linux Disk"

From Richard's Wiki
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
 
* tune2fs -m 1 /dev/sdb1 # change reserved blocks to only 1%
 
* tune2fs -m 1 /dev/sdb1 # change reserved blocks to only 1%
 
* e2label /dev/sdb1 "ext4_2TB_a_WhateverYouWant" # label the new filesystem
 
* e2label /dev/sdb1 "ext4_2TB_a_WhateverYouWant" # label the new filesystem
 +
* cfdisk /dev/sdb # have a look at the partition table
 
* mkdir /media/disk1 # create a mount point
 
* mkdir /media/disk1 # create a mount point
 
* chmod 777 /media/disk1 # make it writeable by everyone
 
* chmod 777 /media/disk1 # make it writeable by everyone
Line 16: Line 17:
 
** /dev/sdb1      /media/disk1    ext4    defaults        0      2
 
** /dev/sdb1      /media/disk1    ext4    defaults        0      2
 
* mount /dev/sdb1
 
* mount /dev/sdb1
 +
 +
----
 +
If you want to share the drive via Samba, edit /etc/samba/smb.conf :
 +
[disk2]
 +
comment = Disk 2
 +
path = /media/disk2
 +
public = yes
 +
writable = yes
 +
create mask = 0664
 +
directory mask = 0775
 +
force user = rk
 +
force group = rk

Latest revision as of 01:58, 21 December 2012

To add a new disk drive to (ubuntu) linux system, do this (Ubunu Community Documentation - Installing A New Hard Drive):

  • sudo bash # need to run as root
  • lshw -C disk # to list drives in the machine
    • From lshw find the logical name of the new drive. Say /dev/sdb
  • fdisk /dev/sdb # create a partition table
    • n # new partition
    • p # primary partition
    • 1 # partition 1
    • w # write partition table to disk
  • mkfs -t ext4 /dev/sdb1 # make an ext4 filesystem, on partition 1 of disk
  • tune2fs -m 1 /dev/sdb1 # change reserved blocks to only 1%
  • e2label /dev/sdb1 "ext4_2TB_a_WhateverYouWant" # label the new filesystem
  • cfdisk /dev/sdb # have a look at the partition table
  • mkdir /media/disk1 # create a mount point
  • chmod 777 /media/disk1 # make it writeable by everyone
  • edit /etc/fstab, add this (so disk is mounted at reboot):
    • /dev/sdb1 /media/disk1 ext4 defaults 0 2
  • mount /dev/sdb1

If you want to share the drive via Samba, edit /etc/samba/smb.conf :

[disk2]
comment = Disk 2
path = /media/disk2
public = yes
writable = yes
create mask = 0664
directory mask = 0775
force user = rk
force group = rk