linux删除硬盘(linux 删除硬盘)
来源:http://www.tudoupe.com时间:2023-06-10
linux新添加的硬盘可以删除吗
备份了数据就可以删啊,当然也要看具体配置,比如有没有挂载该硬盘到重要路径,没弄清楚就删可能导致系统无法正常启动。

linux下如何删除磁盘分区
分区示例:比如分/dev/sda 硬盘 #: fdisk /dev/sdaThe number of cylinders for this disk is set to 19457.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): m #帮助,输入MCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partition删除一个分区l list known partition typesm print this menun add a new partition 创建一个新的分区o create a new empty DOS partition tablep print the partition table 打印分区表q quit without saving changes 退出不保存s create a new empty Sun disklabelt 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): d #删除分区Partition number (1-8): 2Command (m for help): p # 打印分区表Disk /dev/sda: 160.0 GB, 160041885696 bytes255 heads, 63 sectors/track, 19457 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x0003ce53Device BootStart EndBlocks IdSystem/dev/sda1 * 13825307200007HPFS/NTFS/dev/sda37650 11474307200007HPFS/NTFS/dev/sda4 11475 1945764123447+ 5Extended/dev/sda5 11475 1444423856472+ 7HPFS/NTFS/dev/sda6 19247 19457 1694826 82Linux swap / Solaris/dev/sda7 14445 15660 9767488+83Linux/dev/sda8 15661 1924628804513+83LinuxPartition table entries are not in disk orderCommand (m for help): n #建立新分区Command actionl logical (5 or over)p primary partition (1-4)p #主分区Selected partition 2First cylinder (3825-19457, default 3825): 可以选Using default value 3825Last cylinder, +cylinders or +size{K,M,G} (3825-7649, default 7649): 输入分区大小 比如100GUsing default value 7649 Command (m for help):
以RH9为例,上面有只有两个分区/dev/sda1 和/dev/sda2 #fdisk /dev/sda(注意sda后不要加数字)command(m for help):m 输入m后,就会看到很多命令command(m for help): p 输出当前磁盘的状态command(m for help): q想要不存储离开吗?按下q,请不要随便按w新增分区:#fdisk /dev/sdacommand(m for help): n此时系统会提示新增P(主分区)还是E(扩展分区),系统一般是(4个P)+E,而且E分区号必须从5开始p这里自行决定是P还是EPartition number(1-4):3编号可以随意First cylinder:这里按下ENTER就行了Last cylinder or ..............:+100M再输入P的时候就能看到新增的分区了删除分区:#fdisk /dev/sdacommand(m for help): d选择分区号记住q---不存储离开 w---存储离开附上容易混淆的两个命令: df(disk free)---显示磁盘的文件系统与使用情形 du(disk usage)---显示指定的目录或文件所占用的磁盘空间
你是要删除还是卸载?卸载的话用umount 删除用rm
一楼的你看好了 ,lz问的不是删除文件是删除分区 rm你想删什么?可以用系统盘进行分区的修改
以RH9为例,上面有只有两个分区/dev/sda1 和/dev/sda2 #fdisk /dev/sda(注意sda后不要加数字)command(m for help):m 输入m后,就会看到很多命令command(m for help): p 输出当前磁盘的状态command(m for help): q想要不存储离开吗?按下q,请不要随便按w新增分区:#fdisk /dev/sdacommand(m for help): n此时系统会提示新增P(主分区)还是E(扩展分区),系统一般是(4个P)+E,而且E分区号必须从5开始p这里自行决定是P还是EPartition number(1-4):3编号可以随意First cylinder:这里按下ENTER就行了Last cylinder or ..............:+100M再输入P的时候就能看到新增的分区了删除分区:#fdisk /dev/sdacommand(m for help): d选择分区号记住q---不存储离开 w---存储离开附上容易混淆的两个命令: df(disk free)---显示磁盘的文件系统与使用情形 du(disk usage)---显示指定的目录或文件所占用的磁盘空间
你是要删除还是卸载?卸载的话用umount 删除用rm
一楼的你看好了 ,lz问的不是删除文件是删除分区 rm你想删什么?可以用系统盘进行分区的修改

如何安全的删除Linux LVM中的PV物理卷(硬盘或分区)
情况介绍: 一、由于硬盘或者分区的操作方式其实都一样,所以我这里就以分区为例。 二、/home分区2.6G,由如下pv组成: /dev/sda5 100M /dev/sda6 200M /dev/sda7 300M /dev/sda8 400M /dev/sda9 500M /dev/sda10 600M /dev/sda11 500M 很碎对吧?^_^因为测试。 三、随机写了一堆文件进去,用量达到了2G,空闲500M 四、准备将sda6这个200M的PV卸掉(卸掉的容量必须小于空闲容量) 好了开始具体操作了。 卸载分区(缩小操作必须卸载才能进行): umount /home 缩小分区: e2fsck -f /dev/liuhg_disk/home resize2fs /dev/liuhg_disk/home 2200M 首先将分区缩小到2200M这是为了给sda6腾出空间,sda6为200M,而我腾出了400M,因此应该是足够的。 缩小逻辑卷: lvreduce -L 2200M /dev/liuhg_disk/home 分区缩小了用到的逻辑卷也要随着缩小,并查看PV使用的状态: pvdisplay -m 显示如下: --- Physical volume --- PV Name /dev/sda5 VG Name liuhg_disk PV Size 103.26 MiB / not usable 3.26 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 25 Free PE 0 Allocated PE 25 PV UUID 5lnx52-b4jc-OOfZ-f2QA-ttdQ-DZeD-Ce3rb3 --- Physical Segments --- Physical extent 0 to 24: Logical volume /dev/liuhg_disk/home Logical extents 0 to 24 --- Physical volume --- PV Name /dev/sda6 VG Name liuhg_disk PV Size 203.92 MiB / not usable 3.92 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 50 Free PE 0 <-----太悲剧了,sda6里写满了数据一点不剩 Allocated PE 50 <-----这50PE的数据要挪走才行,否则数据就丢了,并且存放的地方也必须是连续的至少50PE PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK --- Physical Segments --- Physical extent 0 to 49: Logical volume /dev/liuhg_disk/home Logical extents 25 to 74 --- Physical volume --- PV Name /dev/sda7 VG Name liuhg_disk PV Size 305.89 MiB / not usable 1.89 MiB Allocatable yes PE Size 4.00 MiB Total PE 76 Free PE 76 <---这个分区有76个空余,因此预计装那50个是不会有问题的 Allocated PE 0 PV UUID 9CFnlx-CAEw-CSul-Rig9-FiCN-zK0a-oGmTEP --- Physical Segments --- Physical extent 0 to 75: FREE --- Physical volume --- PV Name /dev/sda8 VG Name liuhg_disk PV Size 407.87 MiB / not usable 3.87 MiB Allocatable yes PE Size 4.00 MiB Total PE 101 Free PE 60 Allocated PE 41 PV UUID X0I8p0-x2xr-2xLG-QQD4-jbtS-3C4i-xPn4Bl --- Physical Segments --- Physical extent 0 to 40: Logical volume /dev/liuhg_disk/home Logical extents 471 to 511 Physical extent 41 to 100: FREE --- Physical volume --- PV Name /dev/sda9 VG Name liuhg_disk PV Size 509.84 MiB / not usable 1.84 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 127 Free PE 0 Allocated PE 127 PV UUID avJQaA-oMKt-NEoJ-ojBK-2Csc-1dca-1mh6Ue --- Physical Segments --- Physical extent 0 to 126: Logical volume /dev/liuhg_disk/home Logical extents 225 to 351 --- Physical volume --- PV Name /dev/sda10 VG Name liuhg_disk PV Size 603.98 MiB / not usable 3.98 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 150 Free PE 0 Allocated PE 150 PV UUID JlMIAF-A49n-M6HA-ZLXf-d8nS-pfZr-YeQsKT --- Physical Segments --- Physical extent 0 to 149: Logical volume /dev/liuhg_disk/home Logical extents 75 to 224 --- Physical volume --- PV Name /dev/sda11 VG Name liuhg_disk PV Size 478.47 MiB / not usable 2.47 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 119 Free PE 0 Allocated PE 119 PV UUID xnHJNA-tDVx-dryX-KM1x-g96Y-sptI-9iUOcU --- Physical Segments --- Physical extent 0 to 118: Logical volume /dev/liuhg_disk/home Logical extents 352 to 470 将sda6设置为离线状态: pvchange -xn /dev/sda6 使用pvdisplay -m 显示如下: …… --- Physical volume --- PV Name /dev/sda6 VG Name liuhg_disk PV Size 203.92 MiB / not usable 3.92 MiB Allocatable NO <-----表示已经关闭了该PV PE Size 4.00 MiB Total PE 50 Free PE 0 Allocated PE 50 PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK …… 将sda6的数据移走: pvmove -i 1 /dev/sda6 -i 1是每1秒钟报告一次数据迁移的进度。 [root@liuhg /]# pvmove -i 1 /dev/sda6 /dev/sda6: Moved: 38.0% /dev/sda6: Moved: 84.0% /dev/sda6: Moved: 100.0% 重新用pvdisplay -m 显示如下: …… --- Physical volume --- PV Name /dev/sda6 VG Name liuhg_disk PV Size 203.92 MiB / not usable 3.92 MiB Allocatable NO PE Size 4.00 MiB Total PE 50 Free PE 50 <----显示完全空闲和Total PE数一致 Allocated PE 0 PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK …… 从卷组里把sda6删除: [root@liuhg /]# vgreduce liuhg_disk /dev/sda6 Removed "/dev/sda6" from volume group "liuhg_disk" pvdisplay -m再看看吧: --- NEW Physical volume --- <-----还告诉你这是一个新的PV ^_^ PV Name /dev/sda6 VG Name <-----空了 PV Size 203.92 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID S2ane6-nlFG-uSNR-35NP-Yxa6-cXRb-r8E8mK 到此vgdisplay -v能看到已经没有了/dev/sda6了。重新挂载/home [root@liuhg /]# mount /dev/liuhg_disk/home /home [root@liuhg /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 2.0G 546M 1.3G 30% / tmpfs 504M 0 504M 0% /dev/shm /dev/mapper/liuhg_disk-home 2.2G 1.8G 42M 98% /home 进去看看数据,一个都没丢。

linux下如何删除磁盘分区
分区示例:比如分/dev/sda 硬盘 #: fdisk /dev/sda The number of cylinders for this disk is set to 19457. 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): 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): d #删除分区 Partition number (1-8): 2 Command (m for help): p # 打印分区表 Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0003ce53 Device BootStart EndBlocks IdSystem /dev/sda1 * 13825307200007HPFS/NTFS /dev/sda37650 11474307200007HPFS/NTFS /dev/sda4 11475 1945764123447+ 5Extended /dev/sda5 11475 1444423856472+ 7HPFS/NTFS /dev/sda6 19247 19457 1694826 82Linux swap / Solaris /dev/sda7 14445 15660 9767488+83Linux /dev/sda8 15661 1924628804513+83Linux Partition table entries are not in disk order Command (m for help): n #建立新分区 Command action l logical (5 or over) p primary partition (1-4) p #主分区 Selected partition 2 First cylinder (3825-19457, default 3825): 可以选 Using default value 3825 Last cylinder, +cylinders or +size{K,M,G} (3825-7649, default 7649): 输入分区大小 比如100G Using default value 7649 Command (m for help):
fdisk /dev/sdad #删除1 #删除第一个分区w#保存退出总共4个步骤!
有个叫gparted的图形化操作工具,处理起来比较简单。
fdisk /dev/sdad #删除1 #删除第一个分区w#保存退出总共4个步骤!
有个叫gparted的图形化操作工具,处理起来比较简单。

linux安全删除移动硬盘
如过是挂载了要umount,图形界面是插上自动mount,拔的时候点拔出,他会做umount,不然可能会坏,或丢文件。 后来微软都说了其实可以直接插拔。可是,确实有弄坏的概率……

下一篇:没有了
相关新闻
- 2023-01-06 linux删除硬盘(Linux删除目录)
- 2022-10-16 linux删除硬盘(linux删除挂载硬盘的目
|
|