[ubuntu] 外挂硬盘
1. 查看磁盘信息
fdisk -l
这里我需要对sda进行分区,所以要进到sda中
2. 进到欲分区磁盘中
$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.27.).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
3. 按照提示查看信息:
Command (m for help): m Help: DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition Misc
m print this menu
u change display/entry units
x extra functionality (experts only) Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file Save & Exit
w write table to disk and exit
q quit without saving changes Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table Command (m for help): p
Disk /dev/sda: 238.5 GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type
/dev/sda1 * 100G HPFS/NTFS/exFAT
4. 分区
可以看到,在我的sda中,4096到209723391部分已经分给了sda1,剩余空间可以进行分区,剩余空间的起止:209723392到500118191.
Command (m for help): n
Partition type
p primary ( primary, extended, free)
e extended (container for logical partitions)
Select (default p): e
Partition number (-, default ):
First sector (-, default ):
Last sector, +sectors or +size{K,M,G,T,P} (-, default ): Created a new partition of type 'Extended' and of size 138.5 GiB.
5. 分区完成,查看分区情况
Command (m for help): p
Disk /dev/sda: 238.5 GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type
/dev/sda1 * 100G HPFS/NTFS/exFAT
/dev/sda2 .5G Extended
6. 保存退出
注意,以上部分是更新的分区表,并未真正进行物理的分区,需要 键入 “w” 保存退出后才正式生效。
7. 修改格式为 ext4:
报错:
$ sudo mkfs -t ext4 /dev/sda2
mke2fs 1.42. (-May-)
Found a dos partition table in /dev/sda2
Proceed anyway? (y,n) y
mkfs.ext4: inode_size () * inodes_count () too big for a
filesystem with blocks, specify higher inode_ratio (-i)
or lower inode count (-N).
原因:原类型为extend,需要改为Linux。
change type:
$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.27.).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): p
Disk /dev/sda: 238.5 GiB, bytes, sectors
Units: sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disklabel type: dos
Disk identifier: 0x3370b165 Device Boot Start End Sectors Size Id Type
/dev/sda1 * 100G HPFS/NTFS/exFAT
/dev/sda2 .5G Extended Command (m for help): t
Partition number (,, default ):
Partition type (type L to list all types): Changed type of partition 'Extended' to 'Linux'. Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
之后可以格式化为 ext4
$ sudo mkfs -t ext4 /dev/sda2
mke2fs 1.42. (-May-)
Found a dos partition table in /dev/sda2
Proceed anyway? (y,n) y
Discarding device blocks: done
Creating filesystem with 4k blocks and inodes
Filesystem UUID: bc630198-ae61-45af-a0c2-75e8e97cb5bd
Superblock backups stored on blocks:
, , , , , , , , ,
, , , , Allocating group tables: done
Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done
8. 检查新文件系统
$ sudo fsck -f /dev/sda2
fsck from util-linux 2.27.
e2fsck 1.42. (-May-)
Pass : Checking inodes, blocks, and sizes
Pass : Checking directory structure
Pass : Checking directory connectivity
Pass : Checking reference counts
Pass : Checking group summary information
/dev/sda2: / files (0.0% non-contiguous), / blocks
9. 挂载
自己可以新建一个文件作为挂载点,我在自己的home下 mkdir了new这个文件夹,将这块分区挂载在这里。
$sudo mount /dev/sda2 /home/lsy/new
如果觉得挂载错了,想重新挂载,可以用
$ umount /dev/sda2
之后再用之前的mount命令重新挂载即可。虽然挂载点变了,但是sda2中已经保存的内容不会改变的。
[ubuntu] 外挂硬盘的更多相关文章
- 在win7下装ubuntu(硬盘版安装)及遇到的问题
都怪自己弄什么Ubuntu下的Android Studio,因为GFW,gradle总下载不了,用命令行下载一半关机了,然后Ubuntu就这样被我搞残废了.又张罗着重装. 其实就是参照网上的帖子,算是 ...
- Ubuntu更换硬盘
0x00 背景: 目前ubuntu用的是一个80g的硬盘( 一开始没买硬盘,直接拆了一个老老老老的机子来用),系统16.04, 只有一个/分区 ( /dev/sdb1 ) . 新的硬盘是一块256G的 ...
- 增加虚拟机ubuntu的硬盘
20150526更新验证日记: (1)首先在虚拟机中增加ubuntu的硬盘大小. (2)在ubuntu中使用Gparted软件对新的空间进行分配(傻瓜式) (3)不能直接将磁盘挂载到home下,只能先 ...
- Ubuntu挂载硬盘,修改卷标
Ubuntu挂载硬盘,修改卷标转载2016-03-06 17:03:21标签:ubuntu Ubuntu不像windows,硬盘插入电脑不会自动读取硬盘 数据,需要把硬盘挂载到文件夹上,然后才能访问硬 ...
- 扩大ubuntu虚拟机硬盘空间
一.背景: 出于测试的需要,在ubuntu 14.04系统中通过virtualbox虚拟机安装了额ubuntu 14.04系统(guest os).安装过程采用ubuntu 14.04的默认分区方法. ...
- Ubuntu 固态硬盘 4K对齐及启用 Trim,及其验证方法
因为之前一个移动硬盘因为坏道蔓延导致没办法继续使用,我略冲动地跑去买了一块 120GB 的三星840 固态硬盘回来.为了使用起来更方便,还去弄了个光驱位硬盘托架,把固态硬盘接在了光驱位与原本的笔记本硬 ...
- 怎样在win7下装ubuntu(硬盘版安装)
1)首先还是分区,在计算机上右键--管理--磁盘管理 装Ubuntu分配的硬盘大小最好是(20G以上)不要太小,这里请注意,ubuntu和windows文件系统全然不同,所以我们划好要给ubuntu的 ...
- Debian/Ubuntu清理硬盘空间的8个技巧
1. 删除残余的配置文件 通常Debian/Ubuntu删除软件包可以用两条命令 sudo apt-get remove <package-name> sudo apt-get purge ...
- VirtualBox如何扩展虚拟机Ubuntu的硬盘容量-转
https://blog.csdn.net/ouyang_peng/article/details/53261599 摘录要点: 扩展 VBoxManage modifyhd YOUR_HARD_DI ...
随机推荐
- workerman stop失败
1.官网说明:https://www.bookstack.cn/read/workerman-manual/faq-stop-fail.md 2.workerman.pid 中的有一个pid号,置为空 ...
- QT编译Mysql驱动问题及解决方案
默认情况下,qt 并没有自带mysql的数据库插件,需要自己编译先安装mysql server ,运行setup.exe时选择自定义安装,安装目录设为"D:\mysqldev"不要 ...
- 将java文件编译成class文件
一般情况下,在myeclipse中保存java文件后会自动编译成class文件,但是这种情况只能编译当前工程的java文件,但是如果需要编译不是一个工程的java文件,比如在网上拷贝的java文件改如 ...
- Centos7:ActiveMQ安装,配置及使用
解压缩ActiveMQ 的压缩包 使用 命令在bin目录下 ./activemq stat//开启 ./activemq stop//关闭 ./activemq status//状态 进入管理后台 U ...
- Windows 10 安装FileZilla Server
在windows 10本机安装了FileZilla Server 本机用FilleZilla Client连接localhost或者192.168.0.197 port 21 都可以连通,但是在同 ...
- 1 C# 将对象序列化
public static string ObjectToXml(object obj) { using (MemoryStream memoryStream = new MemoryStream() ...
- DHCP显示
两种PXE启动芯片 开机显示:Inter® Boot Agent GE V1.2.45或者Intel UNDI PXE2.0 (Build 082):其中UNDI是Universal Network ...
- CentOS7磁盘空间不足,却找不到占用空间的大文件
1 df -ah 显示/根目录占用百分之九十 进入根目录对指定的文件夹查询容量 cd / du -sh * | sort -n 磁盘有50G,加起来有10G左右的文件找不到 2 自己影响中,已经清理 ...
- (六)buildroot使用详解
为什么要使用buildroot? (文件系统搭建,强烈建议直接用buildroot,官网[http://buildroot.uclibc.org/]上有使用教程非常详细)文件系统通常要包含很多第三方软 ...
- DNS负载均衡与NGINX负载均衡策略
负载均衡是指的是把请求均匀的分摊到多个服务器上处理.一般常见的负载均衡有两种:①客户端与反向代理服务器之间的DNS负载均衡②反向代理服务器与应用服务器之间的负载均衡(这种负载均衡有很多,可以是webl ...