目录
  1. 1. BLFS构建05-文件系统和磁盘管理
    1. 1.1. 构建一个initramfs
    2. 1.2. btrfs-progs
    3. 1.3. dosfstools
    4. 1.4. fuse
    5. 1.5. fuse2.9.7
    6. 1.6. jfsutils
    7. 1.7. 软件磁盘阵列mdadm
    8. 1.8. parted
    9. 1.9. ntfs-3g(微软ntfs)
    10. 1.10. gptfdisk
    11. 1.11. reiserfsprogs
    12. 1.12. smartmontools
    13. 1.13. sshfs
    14. 1.14. xfsprogs
BLFS构建05-文件系统和磁盘管理

BLFS构建05-文件系统和磁盘管理

构建一个initramfs

  • 创建安装脚本/sbin/mkinitramfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
cat > /sbin/mkinitramfs << "EOF"
#!/bin/bash
# This file based in part on the mkinitramfs script for the LFS LiveCD
# written by Alexander E. Patrakov and Jeremy Huntwork.

copy()
{
local file

if [ "$2" == "lib" ]; then
file=$(PATH=/lib:/usr/lib type -p $1)
else
file=$(type -p $1)
fi

if [ -n $file ] ; then
cp $file $WDIR/$2
else
echo "Missing required file: $1 for directory $2"
rm -rf $WDIR
exit 1
fi
}

if [ -z $1 ] ; then
INITRAMFS_FILE=initrd.img-no-kmods
else
KERNEL_VERSION=$1
INITRAMFS_FILE=initrd.img-$KERNEL_VERSION
fi

if [ -n "$KERNEL_VERSION" ] && [ ! -d "/lib/modules/$1" ] ; then
echo "No modules directory named $1"
exit 1
fi

printf "Creating $INITRAMFS_FILE... "

binfiles="sh cat cp dd killall ls mkdir mknod mount "
binfiles="$binfiles umount sed sleep ln rm uname"
binfiles="$binfiles readlink basename"

# Systemd installs udevadm in /bin. Other udev implementations have it in /sbin
if [ -x /bin/udevadm ] ; then binfiles="$binfiles udevadm"; fi

sbinfiles="modprobe blkid switch_root"

#Optional files and locations
for f in mdadm mdmon udevd udevadm; do
if [ -x /sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
done

unsorted=$(mktemp /tmp/unsorted.XXXXXXXXXX)

DATADIR=/usr/share/mkinitramfs
INITIN=init.in

# Create a temporary working directory
WDIR=$(mktemp -d /tmp/initrd-work.XXXXXXXXXX)

# Create base directory structure
mkdir -p $WDIR/{bin,dev,lib/firmware,run,sbin,sys,proc,usr}
mkdir -p $WDIR/etc/{modprobe.d,udev/rules.d}
touch $WDIR/etc/modprobe.d/modprobe.conf
ln -s lib $WDIR/lib64
ln -s ../bin $WDIR/usr/bin

# Create necessary device nodes
mknod -m 640 $WDIR/dev/console c 5 1
mknod -m 664 $WDIR/dev/null c 1 3

# Install the udev configuration files
if [ -f /etc/udev/udev.conf ]; then
cp /etc/udev/udev.conf $WDIR/etc/udev/udev.conf
fi

for file in $(find /etc/udev/rules.d/ -type f) ; do
cp $file $WDIR/etc/udev/rules.d
done

# Install any firmware present
cp -a /lib/firmware $WDIR/lib

# Copy the RAID configuration file if present
if [ -f /etc/mdadm.conf ] ; then
cp /etc/mdadm.conf $WDIR/etc
fi

# Install the init file
install -m0755 $DATADIR/$INITIN $WDIR/init

if [ -n "$KERNEL_VERSION" ] ; then
if [ -x /bin/kmod ] ; then
binfiles="$binfiles kmod"
else
binfiles="$binfiles lsmod"
sbinfiles="$sbinfiles insmod"
fi
fi

# Install basic binaries
for f in $binfiles ; do
if [ -e /bin/$f ]; then d="/bin"; else d="/usr/bin"; fi
ldd $d/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
copy $d/$f bin
done

# Add lvm if present
if [ -x /sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi

for f in $sbinfiles ; do
ldd /sbin/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
copy $f sbin
done

# Add udevd libraries if not in /sbin
if [ -x /lib/udev/udevd ] ; then
ldd /lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
elif [ -x /lib/systemd/systemd-udevd ] ; then
ldd /lib/systemd/systemd-udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
fi

# Add module symlinks if appropriate
if [ -n "$KERNEL_VERSION" ] && [ -x /bin/kmod ] ; then
ln -s kmod $WDIR/bin/lsmod
ln -s kmod $WDIR/bin/insmod
fi

# Add lvm symlinks if appropriate
# Also copy the lvm.conf file
if [ -x /sbin/lvm ] ; then
ln -s lvm $WDIR/sbin/lvchange
ln -s lvm $WDIR/sbin/lvrename
ln -s lvm $WDIR/sbin/lvextend
ln -s lvm $WDIR/sbin/lvcreate
ln -s lvm $WDIR/sbin/lvdisplay
ln -s lvm $WDIR/sbin/lvscan

ln -s lvm $WDIR/sbin/pvchange
ln -s lvm $WDIR/sbin/pvck
ln -s lvm $WDIR/sbin/pvcreate
ln -s lvm $WDIR/sbin/pvdisplay
ln -s lvm $WDIR/sbin/pvscan

ln -s lvm $WDIR/sbin/vgchange
ln -s lvm $WDIR/sbin/vgcreate
ln -s lvm $WDIR/sbin/vgscan
ln -s lvm $WDIR/sbin/vgrename
ln -s lvm $WDIR/sbin/vgck
# Conf file(s)
cp -a /etc/lvm $WDIR/etc
fi

# Install libraries
sort $unsorted | uniq | while read library ; do
if [ "$library" == "linux-vdso.so.1" ] ||
[ "$library" == "linux-gate.so.1" ]; then
continue
fi

copy $library lib
done

if [ -d /lib/udev ]; then
cp -a /lib/udev $WDIR/lib
fi
if [ -d /lib/systemd ]; then
cp -a /lib/systemd $WDIR/lib
fi

# Install the kernel modules if requested
if [ -n "$KERNEL_VERSION" ]; then
find \
/lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage} \
-type f 2> /dev/null | cpio --make-directories -p --quiet $WDIR

cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order} \
$WDIR/lib/modules/$KERNEL_VERSION

depmod -b $WDIR $KERNEL_VERSION
fi

( cd $WDIR ; find . | cpio -o -H newc --quiet | gzip -9 ) > $INITRAMFS_FILE

# Remove the temporary directory and file
rm -rf $WDIR $unsorted
printf "done.\n"
EOF
  • 设置权限
1
chmod 0755 /sbin/mkinitramfs
  • 创建需要的目录和文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
mkdir -p /usr/share/mkinitramfs
cat > /usr/share/mkinitramfs/init.in << "EOF"
#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH

problem()
{
printf "Encountered a problem!\n\nDropping you to a shell.\n\n"
sh
}

no_device()
{
printf "The device %s, which is supposed to contain the\n" $1
printf "root file system, does not exist.\n"
printf "Please fix this problem and exit this shell.\n\n"
}

no_mount()
{
printf "Could not mount device %s\n" $1
printf "Sleeping forever. Please reboot and fix the kernel command line.\n\n"
printf "Maybe the device is formatted with an unsupported file system?\n\n"
printf "Or maybe filesystem type autodetection went wrong, in which case\n"
printf "you should add the rootfstype=... parameter to the kernel command line.\n\n"
printf "Available partitions:\n"
}

do_mount_root()
{
mkdir /.root
[ -n "$rootflags" ] && rootflags="$rootflags,"
rootflags="$rootflags$ro"

case "$root" in
/dev/* ) device=$root ;;
UUID=* ) eval $root; device="/dev/disk/by-uuid/$UUID" ;;
LABEL=*) eval $root; device="/dev/disk/by-label/$LABEL" ;;
"" ) echo "No root device specified." ; problem ;;
esac

while [ ! -b "$device" ] ; do
no_device $device
problem
done

if ! mount -n -t "$rootfstype" -o "$rootflags" "$device" /.root ; then
no_mount $device
cat /proc/partitions
while true ; do sleep 10000 ; done
else
echo "Successfully mounted device $root"
fi
}

init=/sbin/init
root=
rootdelay=
rootfstype=auto
ro="ro"
rootflags=
device=

mount -n -t devtmpfs devtmpfs /dev
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs tmpfs /run

read -r cmdline < /proc/cmdline

for param in $cmdline ; do
case $param in
init=* ) init=${param#init=} ;;
root=* ) root=${param#root=} ;;
rootdelay=* ) rootdelay=${param#rootdelay=} ;;
rootfstype=*) rootfstype=${param#rootfstype=} ;;
rootflags=* ) rootflags=${param#rootflags=} ;;
ro ) ro="ro" ;;
rw ) ro="rw" ;;
esac
done

# udevd location depends on version
if [ -x /sbin/udevd ]; then
UDEVD=/sbin/udevd
elif [ -x /lib/udev/udevd ]; then
UDEVD=/lib/udev/udevd
elif [ -x /lib/systemd/systemd-udevd ]; then
UDEVD=/lib/systemd/systemd-udevd
else
echo "Cannot find udevd nor systemd-udevd"
problem
fi

${UDEVD} --daemon --resolve-names=never
udevadm trigger
udevadm settle

if [ -f /etc/mdadm.conf ] ; then mdadm -As ; fi
if [ -x /sbin/vgchange ] ; then /sbin/vgchange -a y > /dev/null ; fi
if [ -n "$rootdelay" ] ; then sleep "$rootdelay" ; fi

do_mount_root

killall -w ${UDEVD##*/}

exec switch_root /.root "$init" "$@"

EOF
  • 需要依赖cpio
1
2
3
4
5
6
7
8
9
10
11
12
wget https://ftp.gnu.org/gnu/cpio/cpio-2.12.tar.bz2
tar -jxvf cpio-2.12.tar.bz2
cd cpio-2.12
./configure --prefix=/usr --bindir=/bin --enable-mt --with-rmt=/usr/libexec/rmt
make
makeinfo --html -o doc/html doc/cpio.texi
makeinfo --html --no-split -o doc/cpio.html doc/cpio.texi
makeinfo --plaintext -o doc/cpio.txt doc/cpio.texi
make install
install -v -m755 -d /usr/share/doc/cpio-2.12/html
install -v -m644 doc/html/* /usr/share/doc/cpio-2.12/html
install -v -m644 doc/cpio.{html,txt} /usr/share/doc/cpio-2.12
  • 也需要依赖lvm(可以不用)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
wget http://ftp.lfs-matrix.net/pub/blfs/8.4/l/LVM2.2.03.02.tgz
tar -zxvf LVM2.2.03.02.tgz
cd LVM2.2.03.02

SAVEPATH=$PATH &&
PATH=$PATH:/sbin:/usr/sbin &&
./configure --prefix=/usr \
--exec-prefix= \
--enable-cmdlib \
--enable-pkgconfig \
--enable-udev_sync

make
PATH=$SAVEPATH &&
unset SAVEPATH

make -C tools install_dmsetup_dynamic &&
make -C udev install &&
make -C libdm install

make install
  • lvm依赖libaio
1
2
3
4
5
6
wget http://ftp.de.debian.org/debian/pool/main/liba/libaio/libaio_0.3.111.orig.tar.gz
tar -zxvf libaio_0.3.111.orig.tar.gz
cd libaio-0.3.111/
sed -i '/install.*libaio.a/s/^/#/' src/Makefile
make
make install
  • 创建initramfs文件
1
2
3
4
5
6
7
8
9
mkinitramfs
# 编辑grub.cfg文件
# Generic initramfs and root fs identified by UUID
menuentry "LFS Dev (LFS-7.0-Feb14) initrd, Linux 3.0.4"
{
linux /vmlinuz-3.0.4-lfs-20120214 root=UUID=54b934a9-302d-415e-ac11-4988408eb0a8 ro
initrd /initrd.img-no-kmods
}
#使用blkid命令查看磁盘UUID

btrfs-progs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
wget https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v4.20.1.tar.xz
tar -xvf btrfs-progs-v4.20.1.tar.xz
cd btrfs-progs-v4.20.1
./configure --prefix=/usr --bindir=/bin --libdir=/lib --disable-zstd
make
make fssum
sed -i '/found/s/^/: #/' tests/convert-tests.sh
mv tests/mkfs-tests/013-reserved-1M-for-single/test.sh{,.broken} &&
mv tests/convert-tests/010-reiserfs-basic/test.sh{,.broken} &&
mv tests/convert-tests/011-reiserfs-delete-all-rollback/test.sh{,.broken} &&
mv tests/convert-tests/012-reiserfs-large-hole-extent/test.sh{,.broken} &&
mv tests/convert-tests/013-reiserfs-common-inode-flags/test.sh{,.broken} &&
mv tests/convert-tests/014-reiserfs-tail-handling/test.sh{,.broken} &&
mv tests/misc-tests/004-shrink-fs/test.sh{,.broken} &&
mv tests/misc-tests/013-subvolume-sync-crash/test.sh{,.broken} &&
mv tests/misc-tests/025-zstd-compression/test.sh{,.broken} &&
mv tests/fuzz-tests/003-multi-check-unmounted/test.sh{,.broken} &&
mv tests/fuzz-tests/009-simple-zero-log/test.sh{,.broken}

#测试
pushd tests
./fsck-tests.sh
./mkfs-tests.sh
./cli-tests.sh
./convert-tests.sh
./misc-tests.sh
./fuzz-tests.sh
popd

make install

ln -sfv ../../lib/$(readlink /lib/libbtrfs.so) /usr/lib/libbtrfs.so &&
ln -sfv ../../lib/$(readlink /lib/libbtrfsutil.so) /usr/lib/libbtrfsutil.so &&
rm -fv /lib/libbtrfs.{a,so} /lib/libbtrfsutil.{a,so} &&
mv -v /bin/{mkfs,fsck}.btrfs /sbin
  • 安装依赖LZO
1
2
3
4
5
6
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz
tar -zxvf lzo-2.10.tar.gz
cd lzo-2.10
./configure --prefix=/usr --enable-shared --disable-static --disable-static
make
make install
  • 安装依赖xmlto
1
https://releases.pagure.org/xmlto/xmlto-0.0.28.tar.bz2
  • 安装docbook-xml的依赖libxml2,sgml-common和unzip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
wget http://xmlsoft.org/sources/libxml2-2.9.9.tar.gz
wget http://www.w3.org/XML/Test/xmlts20130923.tar.gz
tar -zxvf libxml2-2.9.9.tar.gz
cd libxml2-2.9.9
./configure --prefix=/usr --disable-static --with-history --with-python=/usr/bin/python3
make
tar xf ../xmlts20130923.tar.gz
make install

wget wget http://ftp.lfs-matrix.net/pub/blfs/8.4/s/sgml-common-0.6.3.tgz
wget http://www.linuxfromscratch.org/patches/blfs/8.4/sgml-common-0.6.3-manpage-1.patch
tar -zxvf sgml-common-0.6.3.tgz
cd sgml-common-0.6.3
patch -Np1 -i ../sgml-common-0.6.3-manpage-1.patch
autoreconf -f -i
./configure --prefix=/usr --sysconfdir=/etc
make
make docdir=/usr/share/doc install
install-catalog --add /etc/sgml/sgml-ent.cat /usr/share/sgml/sgml-iso-entities-8879.1986/catalog
install-catalog --add /etc/sgml/sgml-docbook.cat /etc/sgml/sgml-ent.cat

wget wget http://ftp.lfs-matrix.net/pub/blfs/8.4/u/unzip60.tar.gz
tar -zxvf unzip60.tar.gz
cd unzip60
make -f unix/Makefile generic
make prefix=/usr MANDIR=/usr/share/man/man1 -f unix/Makefile install
  • 安装xmlto的依赖docbook-xml,docbook-xsl和libxslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#docbook-xml
mkdir docbook-xml ; mv docbook-xml-4.5.zip docbook-xml
cd docbook-xml
install -v -d -m755 /usr/share/xml/docbook/xml-dtd-4.5
install -v -d -m755 /etc/xml
chown -R root:root .
cp -v -af docbook.cat *.dtd ent/ *.mod /usr/share/xml/docbook/xml-dtd-4.5

#配置docbook
if [ ! -e /etc/xml/docbook ]; then
xmlcatalog --noout --create /etc/xml/docbook
fi &&
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML V4.5//EN" \
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML CALS Table Model V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/calstblx.dtd" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/soextblx.dtd" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML Information Pool V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbpoolx.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbhierx.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML HTML Tables V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/htmltblx.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Notations V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbnotnx.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Character Entities V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbcentx.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Additional General Entities V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbgenent.mod" \
/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteSystem" \
"http://www.oasis-open.org/docbook/xml/4.5" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook &&
xmlcatalog --noout --add "rewriteURI" \
"http://www.oasis-open.org/docbook/xml/4.5" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook

#配置/etc/xml/catalog
if [ ! -e /etc/xml/catalog ]; then
xmlcatalog --noout --create /etc/xml/catalog
fi &&
xmlcatalog --noout --add "delegatePublic" \
"-//OASIS//ENTITIES DocBook XML" \
"file:///etc/xml/docbook" \
/etc/xml/catalog &&
xmlcatalog --noout --add "delegatePublic" \
"-//OASIS//DTD DocBook XML" \
"file:///etc/xml/docbook" \
/etc/xml/catalog &&
xmlcatalog --noout --add "delegateSystem" \
"http://www.oasis-open.org/docbook/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog &&
xmlcatalog --noout --add "delegateURI" \
"http://www.oasis-open.org/docbook/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog

#配置docbook-xml-dtd
for DTDVERSION in 4.1.2 4.2 4.3 4.4
do
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML V$DTDVERSION//EN" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/docbookx.dtd" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteSystem" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteURI" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
xmlcatalog --noout --add "delegateSystem" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
xmlcatalog --noout --add "delegateURI" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
done

#安装docbook-xsl
wget https://github.com/docbook/xslt10-stylesheets/releases/download/release/1.79.2/docbook-xsl-nons-1.79.2.tar.bz2
wget http://www.linuxfromscratch.org/patches/blfs/8.4/docbook-xsl-nons-1.79.2-stack_fix-1.patch
tar -jxvf docbook-xsl-nons-1.79.2.tar.bz2
cd docbook-xsl-nons-1.79.2
patch -Np1 -i ../docbook-xsl-nons-1.79.2-stack_fix-1.patch
tar -xf ../docbook-xsl-doc-1.79.2.tar.bz2 --strip-components=1
install -v -m755 -d /usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2
cp -v -R VERSION assembly common eclipse epub epub3 extensions fo highlighting html htmlhelp images javahelp lib manpages params profiling roundtrip slides template tests tools webhelp website xhtml xhtml-1_1 xhtml5 /usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2
ln -s VERSION /usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2/VERSION.xsl
install -v -m644 -D README /usr/share/doc/docbook-xsl-nons-1.79.2/README.txt
install -v -m644 RELEASE-NOTES* NEWS* /usr/share/doc/docbook-xsl-nons-1.79.2
cp -v -R doc/* /usr/share/doc/docbook-xsl-nons-1.79.2

#配置docbook-xsl
if [ ! -d /etc/xml ]; then install -v -m755 -d /etc/xml; fi &&
if [ ! -f /etc/xml/catalog ]; then
xmlcatalog --noout --create /etc/xml/catalog
fi &&

xmlcatalog --noout --add "rewriteSystem" \
"https://cdn.docbook.org/release/xsl-nons/1.79.2" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog &&

xmlcatalog --noout --add "rewriteURI" \
"https://cdn.docbook.org/release/xsl-nons/1.79.2" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog &&

xmlcatalog --noout --add "rewriteSystem" \
"https://cdn.docbook.org/release/xsl-nons/current" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog &&

xmlcatalog --noout --add "rewriteURI" \
"https://cdn.docbook.org/release/xsl-nons/current" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog &&

xmlcatalog --noout --add "rewriteSystem" \
"http://docbook.sourceforge.net/release/xsl/current" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog &&

xmlcatalog --noout --add "rewriteURI" \
"http://docbook.sourceforge.net/release/xsl/current" \
"/usr/share/xml/docbook/xsl-stylesheets-nons-1.79.2" \
/etc/xml/catalog
#安装libxslt
tar -zxvf libxslt-1.1.33.tar.gz
cd libxslt-1.1.33
sed -i s/3000/5000/ libxslt/transform.c doc/xsltproc.{1,xml}
./configure --prefix=/usr --disable-static
make
make install
  • 安装btfs-ptogs依赖xmlto
1
2
3
4
5
6
wget https://releases.pagure.org/xmlto/xmlto-0.0.28.tar.bz2
tar -jxvf xmlto-0.0.28.tar.bz2
cd xmlto-0.0.28
LINKS="/usr/bin/links" ./configure --prefix=/usr
make
make install
  • 安装btfs-progs依赖asciidoc
1
2
3
4
5
6
7
wget https://downloads.sourceforge.net/asciidoc/asciidoc-8.6.9.tar.gz
tar -zxvf asciidoc-8.6.9.tar.gz
cd asciidoc-8.6.9
./configure --prefix=/usr --sysconfdir=/etc --docdir=/usr/share/doc/asciidoc-8.6.9
make
make install
make docs
  • 安装asciidoc依赖python2.7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
wget https://docs.python.org/ftp/python/doc/2.7.15/python-2.7.15-docs-html.tar.bz2
tar xvf Python-2.7.15.tar.xz
cd Python-2.7.15
./configure --prefix=/usr --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes --enable-unicode=ucs4
make
make install
chmod -v 755 /usr/lib/libpython2.7.so.1.0
install -v -dm755 /usr/share/doc/python-2.7.15
tar --strip-components=1 --no-same-owner --directory /usr/share/doc/python-2.7.15 -xvf ../python-2.7.15-docs-html.tar.bz2
find /usr/share/doc/python-2.7.15 -type d -exec chmod 0755 {} \;
find /usr/share/doc/python-2.7.15 -type f -exec chmod 0644 {} \;
#配置python2
export PYTHONDOCS=/usr/share/doc/python-2.7.15

dosfstools

1
2
3
4
5
6
wget https://github.com/dosfstools/dosfstools/releases/download/v4.1/dosfstools-4.1.tar.xz
tar xvf dosfstools-4.1.tar.xz
cd dosfstools-4.1
./configure --prefix=/ --enable-compat-symlinks --mandir=/usr/share/man --docdir=/usr/share/doc/dosfstools-4.1
make
make install

fuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
wget https://github.com/libfuse/libfuse/releases/download/fuse-3.4.1/fuse-3.4.1.tar.xz
tar xvf fuse-3.4.1.tar.xz
cd fuse-3.4.1
sed -i '/^udev/,$ s/^/#/' util/meson.build
mkdir build &&
cd build
meson --prefix=/usr ..
ninja
ninja install &&

mv -vf /usr/lib/libfuse3.so.3* /lib &&
ln -sfvn ../../lib/libfuse3.so.3.4.1 /usr/lib/libfuse3.so &&

mv -vf /usr/bin/fusermount3 /bin &&
mv -vf /usr/sbin/mount.fuse3 /sbin &&
chmod u+s /bin/fusermount3 &&

install -v -m755 -d /usr/share/doc/fuse-3.4.1 &&
install -v -m644 ../doc/{README.NFS,kernel.txt} \
/usr/share/doc/fuse-3.4.1 &&
cp -Rv ../doc/html /usr/share/doc/fuse-3.4.1
#配置文件
cat > /etc/fuse.conf << "EOF"
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
#user_allow_other
EOF

fuse2.9.7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.7/fuse-2.9.7.tar.gz
tar -zxvf fuse-2.9.7.tar.gz
cd fuse-2.9.7

./configure --prefix=/usr \
--disable-static \
--exec-prefix=/

make
make DESTDIR=$PWD/Dest install

install -vm755 Dest/lib/libfuse.so.2.9.7 /lib &&
install -vm755 Dest/lib/libulockmgr.so.1.0.1 /lib &&
ln -sfv ../../lib/libfuse.so.2.9.7 /usr/lib/libfuse.so &&
ln -sfv ../../lib/libulockmgr.so.1.0.1 /usr/lib/libulockmgr.so &&

install -vm644 Dest/lib/pkgconfig/fuse.pc /usr/lib/pkgconfig &&

install -vm4755 Dest/bin/fusermount /bin &&
install -vm755 Dest/bin/ulockmgr_server /bin &&

install -vm755 Dest/sbin/mount.fuse /sbin &&

install -vdm755 /usr/include/fuse &&

install -vm644 Dest/usr/include/*.h /usr/include &&
install -vm644 Dest/usr/include/fuse/*.h /usr/include/fuse/ &&

install -vm644 Dest/usr/share/man/man1/* /usr/share/man/man1 &&
/sbin/ldconfig -v

jfsutils

1
2
3
4
5
6
7
8
9
wget http://ftp.lfs-matrix.net/pub/blfs/8.4/j/jfsutils-1.1.15.tar.gz
tar -zxvf jfsutils-1.1.15.tar.gz
cd jfsutils-1.1.15

sed -i "/unistd.h/a#include <sys/types.h>" fscklog/extract.c &&
sed -i "/ioctl.h/a#include <sys/sysmacros.h>" libfs/devices.c
./configure
make
make install

软件磁盘阵列mdadm

1
2
3
4
5
6
7
8
9
wget https://www.kernel.org/pub/linux/utils/raid/mdadm/mdadm-4.0.tar.xz
tar -xvf mdadm-4.0.tar.xz
cd mdadm-4.0
sed 's@-Werror@@' -i Makefile
make
sed -i 's# if.* == "1"#& -a -e $targetdir/log#' test
make test
./test --keep-going --logdir=test-logs --save-logs
make install

parted

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
wget https://ftp.gnu.org/gnu/parted/parted-3.2.tar.xz
wget http://www.linuxfromscratch.org/patches/blfs/8.4/parted-3.2-devmapper-1.patch
tar xvf parted-3.2.tar.xz
cd parted-3.2
patch -Np1 -i ../parted-3.2-devmapper-1.patch
sed -i '/utsname.h/a#include <sys/sysmacros.h>' libparted/arch/linux.c
./configure --prefix=/usr --disable-static
make

make -C doc html &&
makeinfo --html -o doc/html doc/parted.texi &&
makeinfo --plaintext -o doc/parted.txt doc/parted.texi
sed -i '/t0251-gpt-unicode.sh/d' tests/Makefile
make install

install -v -m755 -d /usr/share/doc/parted-3.2/html &&
install -v -m644 doc/html/* \
/usr/share/doc/parted-3.2/html &&
install -v -m644 doc/{FAT,API,parted.{txt,html}} \
/usr/share/doc/parted-3.2
install -v -m644 doc/FAT doc/API doc/parted.{pdf,ps,dvi} \
/usr/share/doc/parted-3.2

ntfs-3g(微软ntfs)

1
2
3
4
5
6
7
8
9
10
11
12
13
wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz
tar -zxvf ntfs-3g_ntfsprogs-2017.3.23.tgz
cd ntfs-3g_ntfsprogs-2017.3.23

./configure --prefix=/usr \
--disable-static \
--with-fuse=internal
make

make install &&
ln -sv ../bin/ntfs-3g /sbin/mount.ntfs &&
ln -sv ntfs-3g.8 /usr/share/man/man8/mount.ntfs.8
chmod -v 4755 /bin/ntfs-3g

gptfdisk

1
2
3
4
5
6
7
wget https://downloads.sourceforge.net/gptfdisk/gptfdisk-1.0.4.tar.gz
wget http://www.linuxfromscratch.org/patches/blfs/8.4/gptfdisk-1.0.4-convenience-1.patch
tar -zxvf gptfdisk-1.0.4.tar.gz
cd gptfdisk-1.0.4
patch -Np1 -i ../gptfdisk-1.0.4-convenience-1.patch
make
make install
  • gptfdisk依赖popt
1
2
3
4
5
6
7
8
wget ftp://anduin.linuxfromscratch.org/BLFS/popt/popt-1.16.tar.gz
tar -zxvf popt-1.16.tar.gz
cd popt-1.16
./configure --prefix=/usr --disable-static
make
make install
install -v -m755 -d /usr/share/doc/popt-1.16 &&
install -v -m644 doxygen/html/* /usr/share/doc/popt-1.16

reiserfsprogs

1
2
3
4
5
6
7
8
9
10
wget https://www.kernel.org/pub/linux/kernel/people/jeffm/reiserfsprogs/v3.6.27/reiserfsprogs-3.6.27.tar.xz
tar xvf reiserfsprogs-3.6.27.tar.xz
cd reiserfsprogs-3.6.27
sed -i '/parse_time.h/i #define _GNU_SOURCE' lib/parse_time.c

autoreconf -fiv &&
./configure --prefix=/usr \
--sbindir=/sbin
make
make install

smartmontools

1
2
3
4
5
6
7
8
9
10
11
12
wget https://downloads.sourceforge.net/smartmontools/smartmontools-7.0.tar.gz
tar -zxvf smartmontools-7.0.tar.gz
cd smartmontools-7.0
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-initscriptdir=no \
--docdir=/usr/share/doc/smartmontools-7.0
make
make install
#开机启动
cd /sources/blfs-bootscripts-20180105
make install-smartd

sshfs

  • 需要依赖(fuse(前面已经安装),glib,openssh)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# pcre 
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2
tar -jxvf pcre-8.42.tar.bz2
cd pcre-8.42
./configure --prefix=/usr \
--docdir=/usr/share/doc/pcre-8.42 \
--enable-unicode-properties \
--enable-pcre16 \
--enable-pcre32 \
--enable-pcregrep-libz \
--enable-pcregrep-libbz2 \
--enable-pcretest-libreadline \
--disable-static
make
make install
mv -v /usr/lib/libpcre.so.* /lib &&
ln -sfv ../../lib/$(readlink /usr/lib/libpcre.so) /usr/lib/libpcre.so
#glib
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.58/glib-2.58.3.tar.xz
wget http://www.linuxfromscratch.org/patches/blfs/8.4/glib-2.58.3-skip_warnings-1.patch
tar xvf glib-2.58.3.tar.xz
cd glib-2.58.3
patch -Np1 -i ../glib-2.58.3-skip_warnings-1.patch
mkdir build-glib &&
cd build-glib
meson --prefix=/usr \
-Dman=true \
-Dselinux=false \
.. &&
ninja
#如果缺失这些库,可以从宿主机复制
cp /lib/libglib-2.0.so.0 /mnt/lib/
cp /lib64/libgio-2.0.so.0 /mnt/lib/
cp /lib64/libgobject-2.0.so.0 /mnt/lib/
cp /lib64/libgmodule-2.0.so.0 /mnt/lib/
ninja install &&
mkdir -p /usr/share/doc/glib-2.58.3 &&
cp -r ../docs/reference/{NEWS,gio,glib,gobject} /usr/share/doc/glib-2.58.3

#openssh
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
wget http://www.linuxfromscratch.org/patches/blfs/8.4/openssh-7.9p1-security_fix-1.patch
tar -zxvf openssh-7.9p1.tar.gz
cd openssh-7.9p1
install -v -m700 -d /var/lib/sshd &&
chown -v root:sys /var/lib/sshd

groupadd -g 50 sshd &&
useradd -c 'sshd PrivSep' \
-d /var/lib/sshd \
-g sshd \
-s /bin/false \
-u 50 sshd

patch -Np1 -i ../openssh-7.9p1-security_fix-1.patch
./configure --prefix=/usr \
--sysconfdir=/etc/ssh \
--with-md5-passwords \
--with-privsep-path=/var/lib/sshd
make
make install

install -v -m755 contrib/ssh-copy-id /usr/bin &&

install -v -m644 contrib/ssh-copy-id.1 \
/usr/share/man/man1 &&
install -v -m755 -d /usr/share/doc/openssh-7.9p1 &&
install -v -m644 INSTALL LICENCE OVERVIEW README* \
/usr/share/doc/openssh-7.9p1

#配置openssh
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
#生成秘钥
ssh-keygen &&
ssh-copy-id -i ~/.ssh/id_rsa.pub REMOTE_USERNAME@REMOTE_HOSTNAME

#如果有安装有linux-pam,则执行下面这些语句
sed 's@d/login@d/sshd@g' /etc/pam.d/login > /etc/pam.d/sshd &&
chmod 644 /etc/pam.d/sshd &&
echo "UsePAM yes" >> /etc/ssh/sshd_config

#开机启动
cd /sources/blfs-bootscripts-20180105/
make install-sshd
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config &&
echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config
1
2
3
4
5
6
7
8
wget https://github.com/libfuse/sshfs/releases/download/sshfs-3.5.1/sshfs-3.5.1.tar.xz
tar xvf sshfs-3.5.1.tar.xz
cd sshfs-3.5.1
mkdir build &&
cd build
meson --prefix=/usr ..
ninja
ninja install

xfsprogs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
wget http://ftp.lfs-matrix.net/pub/blfs/8.4/x/xfsprogs-4.19.0.tar.xz
tar xvf xfsprogs-4.19.0.tar.xz
cd xfsprogs-4.19.0
make DEBUG=-DNDEBUG \
INSTALL_USER=root \
INSTALL_GROUP=root \
LOCAL_CONFIGURE_OPTIONS="--enable-readline"

make PKG_DOC_DIR=/usr/share/doc/xfsprogs-4.19.0 install &&
make PKG_DOC_DIR=/usr/share/doc/xfsprogs-4.19.0 install-dev &&

rm -rfv /usr/lib/libhandle.a &&
rm -rfv /lib/libhandle.{a,la,so} &&
ln -sfv ../../lib/libhandle.so.1 /usr/lib/libhandle.so &&
sed -i "s@libdir='/lib@libdir='/usr/lib@" /usr/lib/libhandle.la
1

1

文章作者: rack-leen
文章链接: http://yoursite.com/2019/06/16/BLFS/BLFS%E6%9E%84%E5%BB%BA05-%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%92%8C%E7%A3%81%E7%9B%98%E7%AE%A1%E7%90%86/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 rack-leen's blog
打赏
  • 微信
  • 支付宝

评论