Linux 下挂载新硬盘方法

转载请注明: 转载自 Life吧 本文永久链接地址: http://www.lifeba.org/arch/linux_mount_disk.html

1. 查看未挂载的磁盘
 
[root@localhost ~]# fdisk -l
 
Disk /dev/sda: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       36472   292856917+  8e  Linux LVM
 
Disk /dev/sdb: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
 
从查询结果看出,有一个/dev/sdb的盘未挂载
 
2. 用fdisk 对/dev/sdb 进行分区
 
[root@localhost ~]# fdisk /dev/sdb
 
The number of cylinders for this disk is set to 36472.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-36472, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-36472, default 36472):
Using default value 36472
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
 
再次查看分区情况,多出来一个/dev/sdb1 的区,这个1是我们在前面指定的,如果我们指定2,就变成 sdb2了。
 
[root@localhost ~]# fdisk -l
 
Disk /dev/sda: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       36472   292856917+  8e  Linux LVM
 
Disk /dev/sdb: 300.0 GB, 300000000000 bytes
255 heads, 63 sectors/track, 36472 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       36472   292961308+  83  Linux
 
 
3. 格式化 /dev/sdb1 分区
 
[root@localhost ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
36634624 inodes, 73240327 blocks
3662016 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2236 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616
 
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 
4. 创建data目录并将 /dev/sdb1 挂在到该目录下
 
[root@localhost ~]# ls /
bin   dev  home  lib64       media  mnt  opt   root  selinux  sys  usr
boot  etc  lib   lost+found  misc   net  proc  sbin  srv      tmp  var
 
[root@localhost /]# mkdir /data
[root@localhost /]# mount /dev/sdb1 /data
 
 
5. 验证挂载是否成功
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      254G  2.8G  238G   2% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                  12G     0   12G   0% /dev/shm
/dev/sdb1             276G  192M  261G   1% /data
 
6. 设置开机自动挂载
 
[root@localhost /]# vi /etc/fstab 
 
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb1               /data                   ext3    defaults        1 2


已有 0 人发表留言,猛击->> 这里<<-参与讨论


ITeye推荐
  • —软件人才免语言低担保 赴美带薪读研!—



你可能感兴趣的:(linux,方法,硬盘)