`
fredlong
  • 浏览: 134423 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

玩转linux硬盘加载

阅读更多

1.挂上硬盘之后用fdisk -l来看硬盘的编号:

 

[root@management ~]# fdisk -l

Disk /dev/xvda: 107.4 GB, 107374182400 bytes
//硬盘名为/dev/xvda,一共107.4GB
97 heads, 17 sectors/track, 127177 cylinders
Units = cylinders of 1649 * 512 = 844288 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003827e

Device Boot Start End Blocks Id System
/dev/xvda1 * 2 7632 6291456 83 Linux
//只有一个分区,这个分区从第2个cylinders到7632个cylinders

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

 

可以看出此硬盘有107G,但系统分区(/dev/xvda1)只使用了6G,还有100G没有挂靠到文件系统。

 

 2.fdisk剩余容量分区

 

写道
[root@management ~]# fdisk /dev/xvda
//fdisk 硬盘名

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

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): n
//新建分区

Command action
e extended
p primary partition (1-4)
p
//p为主分区,最多只能有4个主分区

Partition number (1-4): 2
//前面已经有一个主分区了,这块选2


First cylinder (1-127177, default 1): 7633
Last cylinder, +cylinders or +size{K,M,G} (7633-127177, default 127177):
Using default value 127177
//因为第一个分期已经使用了从第2个cylinders到第7632个cylinders,所以这个分期的开始cylinders为7633,截至到最后一个就行

Command (m for help): w
//保存

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
//警告,这次分区变更并没有同步到系统中,需要用partprobe(8) or kpartx(8)同步,或者重启。我这次用partporbe没有成功,还是重启后才搞定。

 

3.mkfs格式化分区

在系统没有获取最新分区信息之前,mkfs的时候会报找不到此分区的错误。

 

[root@management ~]# mkfs -t ext4 /dev/xvda2
mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/xvda2 --- No such file or directory

The device apparently does not exist; did you specify it correctly?

 

重启之后

 

 

写道

 

[root@management ~]# mkfs -t ext4 /dev/xvda2
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6160384 inodes, 24641213 blocks
1232060 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
752 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

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

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

 

4. mount

 

mount后将home下所有数数据迁到这个分区

mkdir /tmpmnt

mount /dev/xvda2 /tmp/mnt

mv /home/* /tmp/mnt

umount /dev/xvda2

mount /dev/xvda2 /home

 

搞定。

 

还有一点需要注意,所有mount到文件系统的分区,都需要到/etc/fstab注册一下,让系统重启的时候把这个分区自动load进来。

 

下面是我们服务器的fstab配置细节,其中最后两行是我们加上的。

写道
#
# /etc/fstab
# Created by anaconda on Mon Jun 9 15:02:26 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=23cecb9c-baa3-4407-9485-ddf59583c3ed / ext4 defaults 1 1
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/xvda2 /home auto defaults,nofail,comment=cloudconfig 0 2

/dev/xvdf /mnt auto defaults,nofail,comment=cloudconfig 0 2

 

 

分享到:
评论

相关推荐

    linux笔录 完整系统的linux命令笔录 让你最短时间玩转linux

    - **`swap`**:交换分区,用于当物理内存不足时,将部分数据临时存放在硬盘上。 #### 目录结构与管理 - **`bin`**:存放用户常用的命令。 - **`sbin`**:包含由超级用户使用的管理命令。 - **`boot`**:存放引导...

    在Win98和Linux下玩转优盘.pdf

    标题中的“在Win98和Linux下玩转优盘”指的是如何在两种不同的操作系统环境下,即Windows 98和Linux中使用USB优盘。优盘作为一种便携式的存储设备,通常用于数据的传输和存储。在不同的操作系统下,其使用方法和注意...

    玩转虚拟机

    "玩转虚拟机"这个主题旨在帮助初学者掌握虚拟机的基本操作,无需实际安装多个操作系统就能实现跨平台学习和测试。虚拟机为用户提供了极大的便利,无论是学习新操作系统、开发和测试软件,还是进行安全研究,都是得力...

    LINUX 24学时教程

    本书详细讲解了用Linux的图形配置工具配置Caldera OpenLinux,通过一个ppp与网络连接、使用K桌面环境、用StarOffice提高在家办公的效率、网络浏览、发传真、...第20学时 休闲与玩Linux操作系统中的 游戏 316 20.1 使用...

    小白带你玩VMware

    在VMware中创建虚拟机后,通过虚拟机的设置,将ISO文件加载到虚拟的DVD驱动器中,从而开始虚拟机的启动。 接下来就是安装过程中的分区选择。在安装Linux系统时,用户可以选择将所有文件放在一个分区中,也可以根据...

    虚拟光驱--虚拟光驱--虚拟光驱

    这样,用户就可以安装软件、玩游戏或者访问数据,就像它们是从实际的光盘上进行的一样。 虚拟光驱的主要功能包括: 1. **创建映像**:用户可以将物理光盘的内容转换成数字映像文件,以便于存储和传输。 2. **加载...

    PowerISO 镜像刻录 制作

    此外,也可以从本地硬盘上的文件和文件夹直接创建自定义的ISO镜像,方便进行备份或分发。 刻录光盘是PowerISO的另一大亮点。它支持刻录各种类型的光盘,如CD、DVD、BD,以及数据盘、音乐盘、视频盘和启动盘。用户...

    虚拟光驱不用重启(英文)

    标签“tools”表明这是一款工具软件,即虚拟光驱软件,通常用于安装软件、玩游戏或者备份光盘数据等场景。 从压缩包子文件的文件名称“虚拟光驱不许重启(英文).exe”来看,这应该是一个可执行文件,是虚拟光驱软件...

    dos_box_rar

    DOSBox还支持软盘、硬盘和光驱模拟,可以通过虚拟的软盘映像(.img文件)和硬盘映像(.iso或.zip文件)来加载软件。 在"描述"中提到了“运行简单的汇编语言”,这暗示了这个压缩包可能包含了一些汇编语言教程或者...

    DTLite4402-0131

    2. **快速加载镜像**:由于数据直接从硬盘读取,加载速度远超实体光盘,大大提高了工作效率。 3. **保护数据安全**:镜像文件可以加密,保护敏感信息不被非法访问。 4. **节省资源**:使用虚拟光驱可以避免物理光驱...

Global site tag (gtag.js) - Google Analytics