给FreeBSD添加一块新的硬盘

给FreeBSD添加一块新的硬盘,第1张

我添加的是一块SCSI的硬盘, 所以新加的硬盘应该是以da0,1....开头. 如果是添加IDE的硬盘, 貌似应该是以ad0,1... 开头的了.

一、默认安装完 freebsd 系统后,可执行df -h命令查看当前硬盘信息:

[root@ www.unixnotes.net /] #df -h

<pre>Filesystem SizeUsed Avail Capacity Mounted on /dev/

da0s1a

140G2.9G126G 2%/ devfs 1.0K1.0K 0B 100%/dev </pre>

从以上信息可知硬盘是

ad0

,好,接下来关机,接上第二个硬盘,开机登陆freebsd系统,执行dmesg命令:

[ root@www.unixnotes.net /]#dmesg

显示以下信息:

<pre>...................................... .........省略部份.................. ......................... ppi0: <parallel o="" i="">on ppbus0 da0

: 139205MB <maxtor el="">[79656/16/63] at ata0-master UDMA100 da1

: 38166MB <st340014a>[77545/16/63] at ata1-master UDMA100 Mounting root from ufs:/dev/ad0s1a</st340014a></maxtor></parallel></pre>

从以上信息可以看到新加的硬盘是

da1,

二、建立newdirectory目录用于挂载第二个硬盘

[ root@www.unixnotes.net /]#cd /

[ root@www.unixnotes.net /]#mkdir newdirectory

情况一,新增加的硬盘是没有数据的,或新增加的硬盘数据是不要的了!

先格式化一下硬盘:

[ root@www.unixnotes.net /]#dd if=/dev/zero of=/dev/da1 bs=1k count=1

始化新磁盘

[ root@www.unixnotes.net /]#fdisk -BI da1

加上标签

[ root@www.unixnotes.net /]#disklabel -B -w -r da1s1 auto

现在编辑你刚才创建的磁盘分区

[ root@www.unixnotes.net /]#disklabel -e da1s1

为你创建的每个分区重复这个操作

[ root@www.unixnotes.net /]#newfs /dev/da1s1c

挂上分区

[ root@www.unixnotes.net /]#mount /dev/da1s1c /newdirectory

情况二,要增加的硬盘是有数据的,而且数据是要保留的,到时要挂载到netdirectory目录的!

加上标签

[ root@www.unixnotes.net /]#disklabel -B -w -r ad2s1 auto

现在编辑你刚才创建的磁盘分区

[ root@www.unixnotes.net /]#disklabel -e ad2s1

挂上分区

[ root@www.unixnotes.net /]#mount /dev/ad2s1c /newdirectory

三、编辑/etc/fstab 文件,添加合适的记录到你的/etc/fstab文件。如我的是增加以下信息:

<pre>/dev/ad2s1c /netdirectory ufs rw 2 2 </pre>

以上空白处用tab键隔开,不是空格,我的是ad2,具体根据dmesg显示的信息修改!如下是我的fstab文件内容:

[ root@www.unixnotes.net /]#vi /etc/fstab

<pre># DeviceMountpoint FStype Options DumpPass# /dev/ad0s1b noneswapsw 0 0 /dev/ad0s1a / ufs rw 1 1 /dev/ad0s1f /tmpufs rw 2 2 /dev/ad0s1g /usrufs rw 2 2 /dev/ad0s1e /varufs rw 2 2 /dev/acd0c /cdrom cd9660 ro,noauto 0 0 proc/proc procfs rw 0 0 /dev/ad2s1c /netdirectory ufs rw 2 2 </pre>

vmware环境安装的freebsd 12.0 运行pkg search python命令时提示 " :write failed, filesystem is full ",意即文件系统满了,无法写入,如下图所示:

运行df -h命令,得到结果:

rootfs容量显示为105%,超过100%了,所以有这个问题出现。

查来查去,觉得还是这个官网论坛的说法靠谱

https://forums.freebsd.org/threads/my-hard-disk-has-109-of-capacity.68366/

最后 ronaldlees 老兄总结到:我楼上的老兄 yuripv 给出一个链接就把一切都讲完了(said it all), 不过,我得多句嘴,答案就是他提到的FAQ页面最下面那项,(except I'll add that the answer is the last item on the page he referenced.)

链接在此: FAQ: https://www.freebsd.org/doc/en/books/faq/disks.html#idp59477704

***********************************************************************************************************8.22.How is it possible for a partition to be more than 100% full?

A portion of each UFS partition (8%, by default) is reserved for use by the operating system and the root user. df(1) does not count that space when calculating the Capacity column, so it can exceed 100%. Notice that the Blocks column is always greater than the sum of the Used and Avail columns, usually by a factor of 8%.

For more details, look up -m in tunefs(8).

**********************************************************************************************************说的是有一个系统保留空间,df命令无法计入,所以导致空间超过100%这种现象,不过到这里依然无法解决问题,不过倒是有了一个思路,就是要对根文件系统作出调整,但tunefs命令不能对活动的文件系统作出更改,(见这个链接 http://www.kbase101.com/question/17960.html )所以继续把自己当作一只网虫,继续爬,通过百度"根文件系统扩容"这个关键词,爬到这个链接: http://ju.outofmemory.cn/entry/329183

1, 使用 gpart show命令查看磁盘空间情况,如下图:

使用freebsd官网提供的虚拟机格式文件vmdk安装的虚拟机配置如下:

默认的硬盘空间4GB觉得可能是小了点,于是关机编辑虚拟机配置,把硬盘容量提高到10GB,开机后,再次使用 gpart show命令查看磁盘空间情况,如下图:

看到多了一个 - free - (空闲空间) 6.0G

2,  使用 “gpart resize -i 3  da0”(这里“3”这个数字对应的是空闲空间的被置换到的分区,像我这种情况,一共就三个分区,一个boot分区,一个swap分区,最后一个是ufs分区)命令来把空闲空间利用上,再用gpart show查看,如图所示:

这一步之后,如果使用 df -h命令查看,会发现,空间空间虽是利用上了,但是根文件系统还没有扩容到,如下图:

3,使用“growfs /dev/gpt/rootfs” 命令对根文件系统进行扩容,会提示要备份,输入yes后,如下图所示:

4,用df -h命令查看文件系统使用情况,发现根文件系统(rootfs)的 容量(Capacity)不再是106%了,而是35%了

参考链接: http://jackxiang.com/post/9454/

由于默认安装没有装软件仓库,所以这里花了一点时间进行pkg更新(一度我认为是联不了网卡住了),最后找了4个版本出来,据说freebsd兼容多版本的软件,这一点相比linux发行版本是一大优势,另外,各位可以试一下,不加参数 grep Interpreted,可以搜出更多有关python的软件。


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/803345.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-08-28
下一篇2023-08-28

发表评论

登录后才能评论

评论列表(0条)

    保存