Skip to content

Instantly share code, notes, and snippets.

@nostream
Created January 7, 2014 01:33
Show Gist options
  • Select an option

  • Save nostream/8293298 to your computer and use it in GitHub Desktop.

Select an option

Save nostream/8293298 to your computer and use it in GitHub Desktop.
linux mount
虚拟机安装的时候只分配了8G的硬盘,现在又分配了250G的磁盘空间,需要挂载上去,下面是挂载步骤
# fdisk -l
#查看分区情况
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM
Disk /dev/sdb: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
# parted /dev/sdb
#使用parted对/dev/sdb进行分区
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable gpt
(parted) mkpart primary 0 -1
#只分一个区
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 268GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 268GB 268GB primary
(parted) quit
Information: Don't forget to update /etc/fstab, if necessary.
[root@scm ~]# mkfs.ext3 -F /dev/sdb1
#将系统格式化为ext3,分区名称为/dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
32768000 inodes, 65535991 blocks
3276799 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2000 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
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.
[root@scm ~]# fdisk -l
#查看磁盘分区
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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 1044 8281507+ 8e Linux LVM
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 32636 262143999+ ee EFI GPT
[root@scm ~]# df -h
#查看磁盘挂载情况,发现250G的磁盘空间还是没有挂载上来
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6.7G 2.8G 3.7G 43% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 250M 0 250M 0% /dev/shm
[root@scm ~]# e2label /dev/sdb1 /scm
#用e2label给/dev/sdb1创建卷标,用/scm来表示/dev/sdb1
[root@scm ~]# vi /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
LABEL=/scm /home ext3 defaults 0 0
#将/dev/sdb1挂载到/home下
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
[root@scm ~]# mount -a
[root@scm ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6.7G 2.9G 3.5G 45% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 250M 0 250M 0% /dev/shm
/dev/sdb1 247G 188M 234G 1% /home
#250G的磁盘空间已经被正确挂载到/home目录下
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment