请问下怎样在tinycore启动的时候自动加载所有的分区?特别是FAT32/NTFS分区?
我用的是TinyCorePure64-12.0.iso,http://www.tinycorelinux.net/12.x/x86_64/release/
54bc11152740fe4b0148521fd5f39639 CorePure64-12.0.iso
我在app中下载了getlocale.tcz,并且用sudo getlocale.sh设置了locale为zh_CN.UTF-8,grub4dos/grub2启动参数里面也添加了 lang=zh_CN.UTF-8
my grub2 menu:
menuentry “/TinyCorePure64-12.0/boot/vmlinuz64” “/TinyCorePure64-12.0/boot/vmlinuz64” {
search —no-floppy —set —file $2;probe -u ($root) -s uuid;echo $uuid
linux $2 quiet loglevel=3 tce=UUID=”$uuid”/TinyCorePure64-12.0/cde/ showapps vga=791 lang=zh_CN.UTF-8 tz=GMT-8
initrd /TinyCorePure64-12.0/boot/corepure64.gz
}
但是启动的时候FAT32/NTFS分区不会被自动挂载,如果用wbar里面的mounttool挂载,会出现乱码的现象。
我是用这样子的命令搞定NTFS/FAT32文件和文件夹乱码的问题的:
sudo mount -t ntfs-3g /dev/sda2 /mnt/sda2
sudo mount -t vfat -o iocharset=utf8 /dev/sdd2 /mnt/sdd2
想请问下,怎样让我硬盘里面所有的FAT32/NTFS分区自动挂载?我已经安装了ntfs-3g.tcz。
sudo passwd root
password:*
su
password:*
vi /etc/fstab
vi是打开文件后的命令模式状态。 可以使用i或a命令进入可编辑状态。
按【ESC】键跳到命令模式,然后再按【:】冒号键,最后再按【wq】,即可保存退出vi的编辑状态;如果是不想保持直接按下【:】冒号键加【q!】键,就能直接退出。
/etc/fstab
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/zram0 swap swap defaults,noauto 0 0
/dev/sda2 /mnt/sda2 ntfs noauto,users,exec,ro,umask=000 0 0 # Added by TC
/dev/sdc3 /mnt/sdc3 vfat noauto,users,exec,umask=000 0 0 # Added by TC
/dev/sdd2 /mnt/sdd2 vfat noauto,users,exec,umask=000 0 0 # Added by TC
/dev/sr0 /mnt/sr0 auto noauto,users,exec 0 0 # Added by TC
改成这样子:
/etc/fstab
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/zram0 swap swap defaults,noauto 0 0
/dev/sda2 /mnt/sda2 ntfs auto,users,exec,ro,umask=000,locale=zh_CN.UTF-8 0 0 # Added by TC
/dev/sdc3 /mnt/sdc3 vfat auto,users,exec,umask=000,locale=zh_CN.UTF-8 0 0 # Added by TC
/dev/sdd2 /mnt/sdd2 vfat auto,users,exec,umask=000,locale=zh_CN.UTF-8 0 0 # Added by TC
/dev/sr0 /mnt/sr0 auto noauto,users,exec 0 0 # Added by TC
我修改之后,保存了/etc/fstab,用xfw看了下,确实修改过了。
然后重启,再看看,还是没有自动挂载,用xfw看了下/etc/fstab,又还原了。
那么就从/usr/sbin/rebuildfstab着手吧。
vi /usr/sbin/rebuildfstab
改成下面的:
!/bin/busybox ash
. /etc/init.d/tc-functions
useBusybox
PATH=”/bin:/sbin:/usr/bin:/usr/sbin”
export PATH
umask 022
Exit if script is already running
[ -e /proc/partitions ] || exit
if [ -e /var/run/rebuildfstab.pid ]; then
if [ -e “/proc/$(cat /var/run/rebuildfstab.pid)” ]; then
touch /var/run/rebuildfstab.rescan 2>/dev/null
exit
fi
rm -f /var/run/rebuildfstab.pid
fi
echo “$$” >/var/run/rebuildfstab.pid
TMP=”/tmp/fstab.$$.tmp”
ADDEDBY=”# Added by TC”
DEVROOT=”/dev”
Create a list of fdisk -l
FDISKL=fdisk -l | awk '$1 ~ /dev/{printf " %s ",$1}'
Read a list of CDROM/DVD Drives
CDROMS=””
CDROMSF=/etc/sysconfig/cdroms
[ -s “$CDROMSF” ] && CDROMS=cat "$CDROMSF"
grep -v “$ADDEDBY” /etc/fstab > “$TMP”
Loop through block devices
for i in find /sys/block/*/ -name dev
; do
case “$i” in
loop|ram)
continue
;;
esac
DEVNAME=echo "$i"| tr [!] [/] | awk 'BEGIN{FS="/"}{print $(NF-1)}'
DEVMAJOR=”$(cat $i|cut -f1 -d:)”
FSTYPE=””
case “$CDROMS” in “$DEVROOT/$DEVNAME”) FSTYPE=”auto” ;; esac
First try blkid approach for FSTYPE for non floppy drives.
[ “$DEVMAJOR” != 2 -a -z “$FSTYPE” ] && FSTYPE=”$(fstype “/dev/$DEVNAME”)”
[ “$FSTYPE” == “linux_raid_member” ] && continue
[ “$FSTYPE” == “LVM2_member” ] && continue
if [ -z “$FSTYPE” ]; then
case "$DEVMAJOR" in
2|98)
FSTYPE="auto"
;;
3|8|11|22|33|34)
case "$FDISKL" in *"$DEVROOT/$DEVNAME "*) FSTYPE="$(fstype $DEVROOT/$DEVNAME)" ;; esac
case "$CDROMS" in *"$DEVROOT/$DEVNAME"*) FSTYPE="auto" ;; esac
;;
179|9|259) # MMC or MD (software raid)
FSTYPE="$(fstype $DEVROOT/$DEVNAME)"
;;
esac
fi
checkntfs() {
if [ -f /usr/local/bin/ntfs-3g ]; then
FSTYPE=”ntfs-3g”
OPTIONS=”$OPTIONS”
else
FSTYPE=”ntfs”
OPTIONS=”$OPTIONS,ro,umask=000”
fi
}
[ -z “$FSTYPE” ] && continue
MOUNTPOINT=”/mnt/$DEVNAME”
OPTIONS=”auto,users,exec”
case “$FSTYPE” in
ntfs) checkntfs ;;
vfat|msdos) OPTIONS=”${OPTIONS},umask=000,iocharset=utf8“ ;;
ext2|ext3) OPTIONS=”${OPTIONS},relatime” ;;
swap) OPTIONS=”defaults”; MOUNTPOINT=”none” ;;
esac
if [ “$MOUNTPOINT” != “none” ]; then
mkdir -p “/mnt/$DEVNAME” 2>/dev/null >/dev/null
fi
grep -q “^$DEVROOT/$DEVNAME “ $TMP ||
printf “%-15s %-15s %-8s %-20s %-s\n” “$DEVROOT/$DEVNAME” “$MOUNTPOINT” “$FSTYPE” “$OPTIONS” “0 0 $ADDEDBY” >>”$TMP”
done
Clean up
mv “$TMP” /etc/fstab
rm -f /var/run/rebuildfstab.pid
sync
If another copy tried to run while we were running, rescan.
if [ -e /var/run/rebuildfstab.rescan ]; then
rm -f /var/run/rebuildfstab.rescan
exec $0 “$@”
fi
重启之后,看了下/usr/sbin/rebuildfstab和/etc/fstab,都回去了,看样子在线修改这两个文件不行,还是要折腾corepure64.gz,解包,修改,打包,太麻烦了。
option修改为auto之后,在/usr/sbin/rebuildfstab后面添加mount -a应该可以实现自动挂载。
尝试写个脚本让分区自动挂载:
mountpartition2.sh
!/bin/busybox ash
. /etc/init.d/tc-functions
useBusybox
sudo mount -t vfat -o iocharset=utf8 /dev/sdd2 /mnt/sdd2
sudo mount -t ntfs-3g /dev/sda2 /mnt/sda2
sudo ./mountpartition2.sh
分区挂载正常了,没有乱码。
问题是这样子写,不通用啊。应该可以基于/usr/sbin/rebuildfstab改改。
在/usr/sbin/rebuildfstab后面添加mount -a应该也可以。
但是怎样改?我不会。在此先行谢过。
最好能在iso之外的某个脚本修改后,让他能够自动加载,自动挂载分区。