ubuntu server 14.04 添加新硬盘

1 关机,安装新硬盘, 然后上电开机。
2 检查是否检测到了新硬盘:
~$ ls -l /dev/sd* 
brw-rw---- 1 root disk 8,  0  5月 23 09:20 /dev/sda
brw-rw---- 1 root disk 8,  1  5月 23 09:20 /dev/sda1
brw-rw---- 1 root disk 8,  2  5月 23 09:20 /dev/sda2
brw-rw---- 1 root disk 8,  5  5月 23 09:20 /dev/sda5
brw-rw---- 1 root disk 8, 16  5月 23 09:20 /dev/sdb

看到了新增加的硬盘为 /dev/sdb

3 查看新硬盘的参数:
~$ sudo hdparm -I /dev/sdb
/dev/sdb:

ATA device, with non-removable media
    Model Number:       ST2000DM006-2DM164                      
    Serial Number:      W4Z4HPJC
    Firmware Revision:  CC26    
    Transport:          Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
    Used: unknown (minor revision code 0x001f)
    Supported: 9 8 7 6 5
    Likely used: 9
Configuration:
    Logical        max    current
    cylinders    16383    16383
    heads        16    16
    sectors/track    63    63
    --
    CHS current addressable sectors:   16514064
    LBA    user addressable sectors:  268435455
    LBA48  user addressable sectors: 3907029168
    Logical  Sector size:                   512 bytes
    Physical Sector size:                  4096 bytes
    Logical Sector-0 offset:                  0 bytes
    device size with M = 1024*1024:     1907729 MBytes
    device size with M = 1000*1000:     2000398 MBytes (2000 GB)
    cache/buffer size  = unknown
    Form Factor: 3.5 inch
    Nominal Media Rotation Rate: 7200
Capabilities:
    LBA, IORDY(can be disabled)
    Queue depth: 32
    Standby timer values: spec‘d by Standard, no device specific minimum
    R/W multiple sector transfer: Max = 16    Current = ?
    Advanced power management level: 254
    Recommended acoustic management value: 208, current value: 208
    DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
         Cycle time: min=120ns recommended=120ns
    PIO: pio0 pio1 pio2 pio3 pio4
         Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
    Enabled    Supported:
       *    SMART feature set
            Security Mode feature set
       *    Power Management feature set
       *    Write cache
       *    Look-ahead
       *    Host Protected Area feature set
       *    WRITE_BUFFER command
       *    READ_BUFFER command
       *    DOWNLOAD_MICROCODE
       *    Advanced Power Management feature set
            Power-Up In Standby feature set
       *    SET_FEATURES required to spinup after power up
            SET_MAX security extension
       *    48-bit Address feature set
       *    Device Configuration Overlay feature set
       *    Mandatory FLUSH_CACHE
       *    FLUSH_CACHE_EXT
       *    SMART error logging
       *    SMART self-test
       *    General Purpose Logging feature set
       *    WRITE_{DMA|MULTIPLE}_FUA_EXT
       *    64-bit World wide name
            Write-Read-Verify feature set
       *    WRITE_UNCORRECTABLE_EXT command
       *    {READ,WRITE}_DMA_EXT_GPL commands
       *    Segmented DOWNLOAD_MICROCODE
            unknown 119[6]
       *    Gen1 signaling speed (1.5Gb/s)
       *    Gen2 signaling speed (3.0Gb/s)
       *    Gen3 signaling speed (6.0Gb/s)
       *    Native Command Queueing (NCQ)
       *    Phy event counters
       *    READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
       *    DMA Setup Auto-Activate optimization
            Device-initiated interface power management
       *    Software settings preservation
            unknown 78[7]
       *    SMART Command Transport (SCT) feature set
       *    SCT Write Same (AC2)
            unknown 206[7]
            unknown 206[12] (vendor specific)
Security:
    Master password revision code = 65534
        supported
    not    enabled
    not    locked
    not    frozen
    not    expired: security count
        supported: enhanced erase
    198min for SECURITY ERASE UNIT. 198min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000c500a8ebeb68
    NAA        : 5
    IEEE OUI    : 000c50
    Unique ID    : 0a8ebeb68
Checksum: correct
4 进行分区,由于我要用这块2T的希捷硬盘做数据盘,因此我将整块硬盘分成一个主分区,不再细分成扩展分区,逻辑分区。现在的系统都是64位的,因此是可以支持2T的主分区。
~$ sudo fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1ab94f32.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won‘t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): m     #输入m查看帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition‘s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p     #打印出硬盘信息

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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
Disk identifier: 0x1ab94f32

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n       #选择new一个分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):       #回车,默认p 主分区
Using default response p
Partition number (1-4, default 1): 1     # 输入1,选择第一个主分区
First sector (2048-3907029167, default 2048):    # 回车,默认起始扇区
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167):   #回车,默认结束扇区
Using default value 3907029167

Command (m for help): p     #打印一下,查看,没有问题

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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
Disk identifier: 0x1ab94f32

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  3907029167  1953513560   83  Linux

Command (m for help): m     #查看帮助,确认要用哪个命令写入。
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition‘s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): w  #输入w,写入并退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
5 查看一下所有的硬盘:
~$ sudo fdisk -l 
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x000b8bcb

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   454848511   227423232   83  Linux
/dev/sda2       454850558   488396799    16773121    5  Extended
/dev/sda5       454850560   488396799    16773120   82  Linux swap / Solaris

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
81 heads, 63 sectors/track, 765633 cylinders, total 3907029168 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
Disk identifier: 0x1ab94f32

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  3907029167  1953513560   83  Linux
6 格式化硬盘,现在的Linux的文件格式都是ext4的格式了,记得几年前还有用ext3的格式。
~$ sudo mkfs -t ext4 /dev/sdb1 
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122101760 inodes, 488378390 blocks
24418919 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14905 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
    102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
7 给新硬盘写个标签。
~$ sudo e2label /dev/sdb1 /ext4-2T-disk-1 
8 给一个挂载点:
mkdir /home/yourname/dir 
9 编辑 /etc/fstab文件:
gedit /etc/fstab 

or

sudo nano /etc/fstab 

在文件的最后一行加入:

LABEL=/ext4-2T-disk-1    /home/yourname/dir    ext4    defaults    0    2
10 挂载
~$ sudo mount -a 
11 这时候,你会发现挂载的盘,普通用户无法写入,需要授权
~$ sudo chown -R $(whoami) /home/yourname/dir
12 扩展硬盘工作完成了
13 新硬盘上新建svn根目录

/home/yourname/dir目录下新建svn目录,编辑 /etc/apache2/apache2.conf 添加如下内容后

<Location /svn2>                   ### need change here!!!
  DAV svn
  SVNPath /home/yourname/dir/svn   ### need change here!!!
  AuthType Basic
  AuthName "Subversion repository"
  AuthUserFile /home/svn_data/passwd
  Require valid-user
</Location>

重启apache2服务器

sudo service apache2 restart
14 新硬盘上新建ftp文件共享目录

/home/yourname/dir目录下新建share目录,编辑 /etc/samba/smb.conf,添加如下内容

[share_disk1]                        ### need change here!!!
    path = /home/yourname/dir/share  ### need change here!!!
    available = yes
    browseable = yes
    public = yes
    writable = yes

重启smb服务器

sudo service smbd restart
15 到此增加硬盘并做相关设置就结束了.

参考地址: https://blog.csdn.net/kangdehua/article/details/72637675

ubuntu server 14.04 添加新硬盘

上一篇:PS快速给MM瘦腿打造迷人性感小腿


下一篇:win7下.net OCIEnvCreate 失败 返回代码为 -1 问题解决办法