2013年7月26日 星期五

Linux建立新的硬碟

fdisk -l
使用fdisk -l列出現有的硬碟~~~

???@???-lubuntu:~$ sudo fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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: 0x000d073b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   124780543    62389248   83  Linux
/dev/sda2       124782590   125827071      522241    5  Extended
/dev/sda5       124782592   125827071      522240   82  Linux swap / Solaris

Disk /dev/sdb: 68.7 GB, 68719476736 bytes
255 heads, 63 sectors/track, 8354 cylinders, total 134217728 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: 0xbbb1368f

   Device Boot      Start         End      Blocks   Id  System

有一顆sdb沒有被分割~~~

使用fdisk /dev/sdb分割硬碟

???@???-lubuntu:~$ sudo fdisk /dev/sdb

Command (m for help): m   //輸入m找help
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): n   //新增partation
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p   //主要磁碟
Partition number (1-4, default 1): 1
First sector (2048-134217727, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-134217727, default 134217727):
Using default value 134217727

Command (m for help): w   //寫入後離開
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

再看一次,已經分割好了~~~

???@???-lubuntu:~$ sudo fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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: 0x000d073b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   124780543    62389248   83  Linux
/dev/sda2       124782590   125827071      522241    5  Extended
/dev/sda5       124782592   125827071      522240   82  Linux swap / Solaris

Disk /dev/sdb: 68.7 GB, 68719476736 bytes
171 heads, 8 sectors/track, 98112 cylinders, total 134217728 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: 0xbbb1368f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   134217727    67107840   83  Linux

使用mkfs.ext3 /dev/sdb1格式化成ext3格式

???@???-lubuntu:~$ sudo mkfs.ext3 /dev/sdb1 
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4194304 inodes, 16776960 blocks
838848 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
512 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

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

沒有留言:

張貼留言