ubuntu from read-only harddisk/cd

本文介绍如何通过unionfs和aufs实现Ubuntu系统的唯读模式,包括安装和配置过程,适用于希望保护系统免受意外更改的用户。

使用 unionfs 及 aufs 的觀念來達成唯讀的功能。
(特別感謝 penk 所製作的 PUD live cd,參考其中的作法才能完成)

※ 已修改好的相關檔案 (請參考附檔)

所需檔案:
(請下載 ftp://mirror.nttu.edu.tw/penk/patch/binary/aufs.ko)
aufs.ko

安裝方法:

1.由 Ubuntu CD 安裝系統及其它軟體 (核心請更新至 2.6.20-16)

2.進入終端機模式,複製 initrd.img-2.6.20-16-generic 到家目錄
cp /boot/initrd.img-2.6.20-16-generic .

3.解開此檔

 

cp initrd.img-2.6.20-16-generic initrd.gz

gunzip initrd.gz

mkdir tmp

cd tmp

cpio  -iF ../initrd.gz 

 

 

4.底下均以 initrd.img-aufs 為工作目錄 (cd initrd.img-aufs)

5.編輯 conf/modules (插入第一列空白列後,輸入 aufs)

6.新增 lib/modules/2.6.20-16-generic/kernel/fs/aufs 資料夾,並複製 aufs.ko 置於此資料夾

7.編輯 scripts/local (方法如下)
移到檔案後方,約在
第 74 列 # Mount root
第 75 列 mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
將 75 列 加上 # 註解
在第 76 列插入下列指令碼:

if [ ${aufsmb} = no ]; then
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
else
modprobe aufs
mkdir -p /rofs
mkdir -p /aufs
mount -t tmpfs -o size=${aufsmb}m /dev/shm /aufs
mount -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} -o ro /rofs
mount -t aufs -o dirs=/aufs=rw:/rofs=ro unionfs ${rootmnt}
fi


8.編輯 init (方法如下)
移到約第 37~44 列 (此處均為 export ??? 型式)
移到最末的 export 後插入一列 export aufsmb=no
移到約第 117 列找到 break=*)
在此列前插入三列,分別輸入
aufs=*)
aufsmb=${x#aufs=}
;;


9.新增兩個文字檔於 scripts/init-bottom/ 資料夾 (名稱為 12fstab 及 13swap)
(特別注意:務必將此兩檔案改成可執行的屬性,chmod +x 12fstab)
------------------------------------------------------
12fstab:
------------------------------------------------------
#!/bin/sh

if [ ${aufsmb} != no ]; then
cat > /root/etc/myfstab1 << EOF
unionfs / unionfs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
EOF
cat /root/etc/fstab | grep '/ ' -v > /root/etc/myfstab2
cat /root/etc/myfstab1 /root/etc/myfstab2 > /root/etc/fstab

rm -f /root/etc/myfstab1
rm -f /root/etc/myfstab2

rm -f /root/etc/rcS.d/S*checkroot.sh
fi

------------------------------------------------------
13swap: (2007.07.31 修改)
------------------------------------------------------
#!/bin/sh

cat /root/etc/fstab | grep 'swap'
if [ $? == 1 ] && [ ${aufsmb} != no ]; then
devices=""
for device in /dev/[hs]d[a-z][0-9]*; do
if ! [ -b "$device" ]; then
continue
fi

magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue

if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
devices="$devices $device"
fi
done

for device in $devices; do
cat >> /root/etc/fstab << EOF
$device swap swap defaults 0 0
EOF


10.製成開機檔 initrd.img-2.6.20-16-aufs
find . | cpio -L -H newc -o | gzip -9 > ../initrd.img-2.6.20-16-aufs

11.複製 initrd.img-2.6.20-16-aufs 到 /boot/ 資料夾
cd ..
sudo cp initrd.img-2.6.20-16-aufs /boot

12.編輯 /boot/grub/menu.lst (複製原有選項,並修改如下)
Title Ubuntu (readonly)
root (hd....)
kernel /boot/vmlinuz-2.6.20-16-generic ....(同原選項) aufs=32
initrd /boot/initrd.img-2.6.20-16-aufs
quiet

註:修改處 Title 及 aufs=32 及 initrd.img-2.6.20-16-aufs
其中 aufs=32 表示使用 32MB RAM 來當做寫入用的緩衝記憶體 (適用於實際記憶體 256MB RAM,可視自己電腦配備調整數字)

13.重新開機後進入 grub 選單時,選擇 Ubuntu, kernel 2.6.20-16-generic (可寫入模式)
或選擇 Ubuntu (readonly) 則進入唯讀模式

make[6]: Entering directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd/modules/hdmi' ccache_cc -O2 -fno-caller-saves -Wno-implicit-fallthrough -Wno-format-truncation -DAI_ENHANCE -DAI_MAX_DEV=6 -D_GNU_SOURCE -DHARDDISK_STORAGE -DUSR_DEF_AUDIO -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/include -I/home/wuyilun/Desktop/CAMEOS/platform/../toolchain/ssd920_sdk/arm-sigmastar-linux-uclibcgnueabihf-9.1.0/arm-sigmastar-linux-uclibcgnueabihf/sysroot/usr/include -I/home/wuyilun/Desktop/CAMEOS/platform/../toolchain/ssd920_sdk/arm-sigmastar-linux-uclibcgnueabihf-9.1.0/arm-sigmastar-linux-uclibcgnueabihf/include -g -Wall -Werror -I./ -I./client/ -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include/libtpsocket -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include/libtpcom -DTAPO_HUB -DMAX_CAM_DEVICE_NUM=16 -DMAX_24H_RECORD_NUMBER=4 -DINDEPENDENT_WIFI_BOARD -DPROTOCOL_SECURE -DDIAGNOSE_LOG_OPTIMIZE -I../../ -DGZIP_SUPPORT -DBASE64_SUPPORT -DNETWORK_SUPPORT -I./modules/network/ -DBLOCKZONE_SUPPORT -I./modules/blockzone/ -DAUDIO_SUPPORT -I./modules/audio_config/ -DCET_SUPPORT -I./modules/cet/ -DDEVICE_INFO_SUPPORT -I./modules/device_info/ -DHARDDISK_MANAGE_SUPPORT -I./modules/harddisk_manage/ -DMIRRORSCREEN_SUPPORT -I./modules/MirrorScreen/ -DIMAGE_SUPPORT -I./modules/image/ -DSYSTEM_SUPPORT -I./modules/system/ -DLED_SUPPORT -I./modules/led/ -DLENS_MASK_SUPPORT -I./modules/lens_mask/ -DMOTION_DETECTION_SUPPORT -I./modules/motion_detection/ -DTAMPER_DETECTION_SUPPORT -I./modules/tamper_detection/ -DMSG_ALARM_SUPPORT -I./modules/msg_alarm/ -DMSG_ALARM_PLAN_SUPPORT -I./modules/msg_alarm_plan/ -DMSG_PUSH_SUPPORT -I./modules/msg_push/ -DMSG_PUSH_PLAN_SUPPORT -I./modules/msg_push_plan/ -DOSD_SUPPORT -I./modules/OSD/ -DPLAYBACK_SUPPORT -I./modules/playback/ -DHUB_PLAYBACK_SUPPORT -I./modules/hubPlayback/ -DRECORD_PLAN_SUPPORT -I./modules/record_plan/ -DTIMING_REBOOT_SUPPORT -I./modules/timing_reboot/ -DVIDEO_SUPPORT -I./modules/video/ -DCLOUD_SUPPORT -I./modules/cloud_config/ -DUSER_MANAGEMENT_SUPPORT -I./modules/user_management/ -DP2P_SUPPORT -I./modules/p2p/ -DRELAY_SUPPORT -I./modules/relay/ -DAPP_COMPONENT_SUPPORT -I./modules/app_component/ -I./modules/onboarding/ -DTAPO_SIREN_SUPPORT -I./modules/siren/ -DAUDIO_CODEC_SUPPORT_EN -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/child_control/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/device_load/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/sub1g_stack_test/ -DTAPO_AUTO_UPGRADE_SUPPORT -I./modules/auto_upgrade/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/pre_wakeup/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/data_download/ -DUSBSHARE_MANAGE_SUPPORT -I./modules/usbshare_manage/ -I./modules/usr_def_audio/ -DAIENHANCE_SUPPORT -I./modules/AIEnhance/ -DTAPO_CHIME_SUPPORT -I./modules/chime/ -DGENERAL_CAMERA_MANAGE_SUPPORT -I./modules/general_camera_manage/ -DCHILD_MIGRATE_EN -I./modules/migrate/ -DUPNP_SUPPORT -I./modules/upnp/ -Wall -Werror -c -o hdmi.o hdmi.c make[6]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd/modules/hdmi' make -C modules/migrate/ MOD_CFLAGS="-DGZIP_SUPPORT -DBASE64_SUPPORT -DNETWORK_SUPPORT -I./modules/network/ -DBLOCKZONE_SUPPORT -I./modules/blockzone/ -DAUDIO_SUPPORT -I./modules/audio_config/ -DCET_SUPPORT -I./modules/cet/ -DDEVICE_INFO_SUPPORT -I./modules/device_info/ -DHARDDISK_MANAGE_SUPPORT -I./modules/harddisk_manage/ -DMIRRORSCREEN_SUPPORT -I./modules/MirrorScreen/ -DIMAGE_SUPPORT -I./modules/image/ -DSYSTEM_SUPPORT -I./modules/system/ -DLED_SUPPORT -I./modules/led/ -DLENS_MASK_SUPPORT -I./modules/lens_mask/ -DMOTION_DETECTION_SUPPORT -I./modules/motion_detection/ -DTAMPER_DETECTION_SUPPORT -I./modules/tamper_detection/ -DMSG_ALARM_SUPPORT -I./modules/msg_alarm/ -DMSG_ALARM_PLAN_SUPPORT -I./modules/msg_alarm_plan/ -DMSG_PUSH_SUPPORT -I./modules/msg_push/ -DMSG_PUSH_PLAN_SUPPORT -I./modules/msg_push_plan/ -DOSD_SUPPORT -I./modules/OSD/ -DPLAYBACK_SUPPORT -I./modules/playback/ -DHUB_PLAYBACK_SUPPORT -I./modules/hubPlayback/ -DRECORD_PLAN_SUPPORT -I./modules/record_plan/ -DTIMING_REBOOT_SUPPORT -I./modules/timing_reboot/ -DVIDEO_SUPPORT -I./modules/video/ -DCLOUD_SUPPORT -I./modules/cloud_config/ -DUSER_MANAGEMENT_SUPPORT -I./modules/user_management/ -DP2P_SUPPORT -I./modules/p2p/ -DRELAY_SUPPORT -I./modules/relay/ -DAPP_COMPONENT_SUPPORT -I./modules/app_component/ -I./modules/onboarding/ -DTAPO_SIREN_SUPPORT -I./modules/siren/ -DAUDIO_CODEC_SUPPORT_EN -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/child_control/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/device_load/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/sub1g_stack_test/ -DTAPO_AUTO_UPGRADE_SUPPORT -I./modules/auto_upgrade/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/pre_wakeup/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/data_download/ -DUSBSHARE_MANAGE_SUPPORT -I./modules/usbshare_manage/ -I./modules/usr_def_audio/ -DAIENHANCE_SUPPORT -I./modules/AIEnhance/ -DTAPO_CHIME_SUPPORT -I./modules/chime/ -DGENERAL_CAMERA_MANAGE_SUPPORT -I./modules/general_camera_manage/ -DCHILD_MIGRATE_EN -I./modules/migrate/ -DUPNP_SUPPORT -I./modules/upnp/ -Wall -Werror" make[6]: Entering directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd/modules/migrate' ccache_cc -O2 -fno-caller-saves -Wno-implicit-fallthrough -Wno-format-truncation -DAI_ENHANCE -DAI_MAX_DEV=6 -D_GNU_SOURCE -DHARDDISK_STORAGE -DUSR_DEF_AUDIO -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/include -I/home/wuyilun/Desktop/CAMEOS/platform/../toolchain/ssd920_sdk/arm-sigmastar-linux-uclibcgnueabihf-9.1.0/arm-sigmastar-linux-uclibcgnueabihf/sysroot/usr/include -I/home/wuyilun/Desktop/CAMEOS/platform/../toolchain/ssd920_sdk/arm-sigmastar-linux-uclibcgnueabihf-9.1.0/arm-sigmastar-linux-uclibcgnueabihf/include -g -Wall -Werror -I./ -I./client/ -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include/libtpsocket -I/home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/usr/include/libtpcom -DTAPO_HUB -DMAX_CAM_DEVICE_NUM=16 -DMAX_24H_RECORD_NUMBER=4 -DINDEPENDENT_WIFI_BOARD -DPROTOCOL_SECURE -DDIAGNOSE_LOG_OPTIMIZE -I../../ -DGZIP_SUPPORT -DBASE64_SUPPORT -DNETWORK_SUPPORT -I./modules/network/ -DBLOCKZONE_SUPPORT -I./modules/blockzone/ -DAUDIO_SUPPORT -I./modules/audio_config/ -DCET_SUPPORT -I./modules/cet/ -DDEVICE_INFO_SUPPORT -I./modules/device_info/ -DHARDDISK_MANAGE_SUPPORT -I./modules/harddisk_manage/ -DMIRRORSCREEN_SUPPORT -I./modules/MirrorScreen/ -DIMAGE_SUPPORT -I./modules/image/ -DSYSTEM_SUPPORT -I./modules/system/ -DLED_SUPPORT -I./modules/led/ -DLENS_MASK_SUPPORT -I./modules/lens_mask/ -DMOTION_DETECTION_SUPPORT -I./modules/motion_detection/ -DTAMPER_DETECTION_SUPPORT -I./modules/tamper_detection/ -DMSG_ALARM_SUPPORT -I./modules/msg_alarm/ -DMSG_ALARM_PLAN_SUPPORT -I./modules/msg_alarm_plan/ -DMSG_PUSH_SUPPORT -I./modules/msg_push/ -DMSG_PUSH_PLAN_SUPPORT -I./modules/msg_push_plan/ -DOSD_SUPPORT -I./modules/OSD/ -DPLAYBACK_SUPPORT -I./modules/playback/ -DHUB_PLAYBACK_SUPPORT -I./modules/hubPlayback/ -DRECORD_PLAN_SUPPORT -I./modules/record_plan/ -DTIMING_REBOOT_SUPPORT -I./modules/timing_reboot/ -DVIDEO_SUPPORT -I./modules/video/ -DCLOUD_SUPPORT -I./modules/cloud_config/ -DUSER_MANAGEMENT_SUPPORT -I./modules/user_management/ -DP2P_SUPPORT -I./modules/p2p/ -DRELAY_SUPPORT -I./modules/relay/ -DAPP_COMPONENT_SUPPORT -I./modules/app_component/ -I./modules/onboarding/ -DTAPO_SIREN_SUPPORT -I./modules/siren/ -DAUDIO_CODEC_SUPPORT_EN -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/child_control/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/device_load/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/sub1g_stack_test/ -DTAPO_AUTO_UPGRADE_SUPPORT -I./modules/auto_upgrade/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/pre_wakeup/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/data_download/ -DUSBSHARE_MANAGE_SUPPORT -I./modules/usbshare_manage/ -I./modules/usr_def_audio/ -DAIENHANCE_SUPPORT -I./modules/AIEnhance/ -DTAPO_CHIME_SUPPORT -I./modules/chime/ -DGENERAL_CAMERA_MANAGE_SUPPORT -I./modules/general_camera_manage/ -DCHILD_MIGRATE_EN -I./modules/migrate/ -DUPNP_SUPPORT -I./modules/upnp/ -Wall -Werror -c -o migrate.o migrate.c make[6]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd/modules/migrate' make -C modules/upnp/ MOD_CFLAGS="-DGZIP_SUPPORT -DBASE64_SUPPORT -DNETWORK_SUPPORT -I./modules/network/ -DBLOCKZONE_SUPPORT -I./modules/blockzone/ -DAUDIO_SUPPORT -I./modules/audio_config/ -DCET_SUPPORT -I./modules/cet/ -DDEVICE_INFO_SUPPORT -I./modules/device_info/ -DHARDDISK_MANAGE_SUPPORT -I./modules/harddisk_manage/ -DMIRRORSCREEN_SUPPORT -I./modules/MirrorScreen/ -DIMAGE_SUPPORT -I./modules/image/ -DSYSTEM_SUPPORT -I./modules/system/ -DLED_SUPPORT -I./modules/led/ -DLENS_MASK_SUPPORT -I./modules/lens_mask/ -DMOTION_DETECTION_SUPPORT -I./modules/motion_detection/ -DTAMPER_DETECTION_SUPPORT -I./modules/tamper_detection/ -DMSG_ALARM_SUPPORT -I./modules/msg_alarm/ -DMSG_ALARM_PLAN_SUPPORT -I./modules/msg_alarm_plan/ -DMSG_PUSH_SUPPORT -I./modules/msg_push/ -DMSG_PUSH_PLAN_SUPPORT -I./modules/msg_push_plan/ -DOSD_SUPPORT -I./modules/OSD/ -DPLAYBACK_SUPPORT -I./modules/playback/ -DHUB_PLAYBACK_SUPPORT -I./modules/hubPlayback/ -DRECORD_PLAN_SUPPORT -I./modules/record_plan/ -DTIMING_REBOOT_SUPPORT -I./modules/timing_reboot/ -DVIDEO_SUPPORT -I./modules/video/ -DCLOUD_SUPPORT -I./modules/cloud_config/ -DUSER_MANAGEMENT_SUPPORT -I./modules/user_management/ -DP2P_SUPPORT -I./modules/p2p/ -DRELAY_SUPPORT -I./modules/relay/ -DAPP_COMPONENT_SUPPORT -I./modules/app_component/ -I./modules/onboarding/ -DTAPO_SIREN_SUPPORT -I./modules/siren/ -DAUDIO_CODEC_SUPPORT_EN -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/child_control/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/device_load/ -DTAPO_DEVICE_LOAD_SUPPORT -I./modules/sub1g_stack_test/ -DTAPO_AUTO_UPGRADE_SUPPORT -I./modules/auto_upgrade/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/pre_wakeup/ -DTAPO_CHILD_CONTROL_SUPPORT -I./modules/data_download/ -DUSBSHARE_MANAGE_SUPPORT -I./modules/usbshare_manage/ -I./modules/usr_def_audio/ -DAIENHANCE_SUPPORT -I./modules/AIEnhance/ -DTAPO_CHIME_SUPPORT -I./modules/chime/ -DGENERAL_CAMERA_MANAGE_SUPPORT -I./modules/general_camera_manage/ -DCHILD_MIGRATE_EN -I./modules/migrate/ -DUPNP_SUPPORT -I./modules/upnp/ -Wall -Werror" make[6]: Entering directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd' make[6]: *** modules/upnp/: No such file or directory. Stop. make[6]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd' make[5]: *** [Makefile:455: modules/upnp/upnp.o] Error 2 make[5]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd' make[4]: *** [Makefile:488: /home/wuyilun/Desktop/CAMEOS/platform/build_dir/target-arm-sigmastar-linux-uclibcgnueabihf/udsd/.built] Error 2 make[4]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform/iplatform/private/udsd' make[3]: *** [package/Makefile:228: package/feeds/iplatform/udsd/compile] Error 2 make[3]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform' make[2]: *** [package/Makefile:224: /home/wuyilun/Desktop/CAMEOS/platform/staging_dir/target-arm-sigmastar-linux-uclibcgnueabihf/stamp/.package_compile] Error 2 make[2]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform' make[1]: *** [/home/wuyilun/Desktop/CAMEOS/platform/include/toplevel.mk:184: world] Error 2 make[1]: Leaving directory '/home/wuyilun/Desktop/CAMEOS/platform' make: *** [Makefile:104: iplatform_world] Error 2
10-24
/home/user/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/dsd/modules/harddisk_manage/disk_safe.c:11: undefined reference to `disk_wrlock' /home/user/nvr_2025/sstar931/toolchain/bin/../lib/gcc/arm-sigmastar-linux-uclibcgnueabihf/9.1.0/../../../../arm-sigmastar-linux-uclibcgnueabihf/bin/ld: /home/user/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/dsd/modules/harddisk_manage/disk_safe.c:55: undefined reference to `disk_mgmt_update_last_wakeup_time' /home/user/nvr_2025/sstar931/toolchain/bin/../lib/gcc/arm-sigmastar-linux-uclibcgnueabihf/9.1.0/../../../../arm-sigmastar-linux-uclibcgnueabihf/bin/ld: /home/user/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/dsd/modules/harddisk_manage/disk_safe.c:66: undefined reference to `disk_rwunlock' /home/user/nvr_2025/sstar931/toolchain/bin/../lib/gcc/arm-sigmastar-linux-uclibcgnueabihf/9.1.0/../../../../arm-sigmastar-linux-uclibcgnueabihf/bin/ld: /home/user/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/dsd/modules/harddisk_manage/disk_safe.c:70: undefined reference to `disk_api_sync_info_to_disk' /home/user/nvr_2025/sstar931/toolchain/bin/../lib/gcc/arm-sigmastar-linux-uclibcgnueabihf/9.1.0/../../../../arm-sigmastar-linux-uclibcgnueabihf/bin/ld: /home/user/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/dsd/modules/harddisk_manage/disk_safe.c:47: undefined reference to `g_disk_mgmt_info'简单来说,我现在引入了另一个头文件,编译时也要加上吗,但是另一个头文件很远,#include "../../../../../tp_package/u_packages/storage/src/include/disk_api.h" #include "../../../../../tp_package/u_packages/storage/src/include/stg_err.h"是这样引入的,要加吗
最新发布
11-21
如下报错是什么原因:arm-linux-gcc -Os -pipe -march=armv7-a -D_GNU_SOURCE -Wno-unused-result -DDISK_LAYOUT_SUB_VERSION=2 -DBQSPEC_FORCEPK_MAINSIZE=2048 -DDEF_GOP_MAINSIZE=2048 -DENABLE_PWRITEV -DHARDDISK_SLOT_CNT=2 -DMAX_UD4REC_NUM_CFG=1 -DMIN_UD4REC_IO_MB_PER_SEC_CFG=20 -DMIN_UD4REC_SPACE_GB_CFG=120 -DSTORAGE_NVR2016H16PV1 -DIPC_CHANNEL_NUM=16 -DWAL_FILE_CNT=5 -DTP_SQLITE3_BACKUP_OP -DTP_FILE_DB_FTRUNCATE -DSQLITE_HAS_CODEC -DTP_FILE_HEAD_OP -DDB_SYNC_CYCLE_NUM=10 -DNVR_HARDDISK_EXTEND_ENABLE -DTARGET_mstar_msr621_nvr2016h16pv1 -DFAN_ENABLE -DDISABLE_NAS -DNO_FALLOCATE -DTP_QUICK_FORMAT -DRECORD_WRITE_CHN_GOP -DDEF_GOP_MAINSIZE=2048 -DRECORD_MEMORY_POOL_BLOCK_SIZE=16384 -DRECORD_MEMORY_POOL_SIZE=60 -DGOPTABLE_FORMAT_DIVIDE -DGOPTABLE_CREATED_UNIT=1000 -DDISK_FORMAT_MUTEX -DRECOVER_DATA_FOR_OUTAGE -DAI_SEARCH -DEXT4_ENABLE -DSMR_LAYOUT_OPTIMIZE -DDIRECT_IO_ALIGN_SIZE=4096 -DMAX_IMAGE_PIC_NUM=400000 -DSLP_ENCPSW_HASH_MD5 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/usr/include -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/include -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/../sstar621/toolchain//arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include -I./include -I./ -shared -fpic -g -Wl,-gc-sections -Wall -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-unused-function -Wno-address -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/include -I/include -Wall -I./include -I./ -L./lib -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/layoutSqlite_v1 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/tpfs_v0 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/tpfs_v1 -shared -fpic -Wall -g -Wl,-gc-sections -c -o dbMgmt.o dbMgmt.c dbMgmt.c: In function 'db_mgmt_reload': dbMgmt.c:1729:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode for (int i = 0; i < 2; i++)
09-04
分析报错内容 arm-linux-gcc -Os -pipe -march=armv7-a -D_GNU_SOURCE -Wno-unused-result -DDISK_LAYOUT_SUB_VERSION=2 -DBQSPEC_FORCEPK_MAINSIZE=2048 -DDEF_GOP_MAINSIZE=2048 -DENABLE_PWRITEV -DHARDDISK_SLOT_CNT=2 -DMAX_UD4REC_NUM_CFG=1 -DMIN_UD4REC_IO_MB_PER_SEC_CFG=20 -DMIN_UD4REC_SPACE_GB_CFG=120 -DSTORAGE_NVR2016H16PV1 -DIPC_CHANNEL_NUM=16 -DWAL_FILE_CNT=5 -DTP_SQLITE3_BACKUP_OP -DTP_FILE_DB_FTRUNCATE -DSQLITE_HAS_CODEC -DTP_FILE_HEAD_OP -DDB_SYNC_CYCLE_NUM=10 -DNVR_HARDDISK_EXTEND_ENABLE -DTARGET_mstar_msr621_nvr2016h16pv1 -DFAN_ENABLE -DDISABLE_NAS -DNO_FALLOCATE -DTP_QUICK_FORMAT -DRECORD_WRITE_CHN_GOP -DDEF_GOP_MAINSIZE=2048 -DRECORD_MEMORY_POOL_BLOCK_SIZE=16384 -DRECORD_MEMORY_POOL_SIZE=60 -DGOPTABLE_FORMAT_DIVIDE -DGOPTABLE_CREATED_UNIT=1000 -DDISK_FORMAT_MUTEX -DRECOVER_DATA_FOR_OUTAGE -DAI_SEARCH -DEXT4_ENABLE -DSMR_LAYOUT_OPTIMIZE -DDIRECT_IO_ALIGN_SIZE=4096 -DMAX_IMAGE_PIC_NUM=400000 -DSLP_ENCPSW_HASH_MD5 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/usr/include -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/staging_dir/target-arm-openwrt-linux-uclibcgnueabihf/include -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/../sstar621/toolchain//arm-buildroot-linux-uclibcgnueabihf/sysroot/usr/include -I./include -I./ -shared -fpic -g -Wl,-gc-sections -Wall -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-unused-function -Wno-address -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/include -I/include -Wall -I./include -I./ -L./lib -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/layoutSqlite_v1 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/tpfs_v0 -I/home/lgb/sharedfile/nvr/nvr_2025/torchlight/build_dir/target-arm-openwrt-linux-uclibcgnueabihf/storage/layout/layouthddb/tpfs_v1 -shared -fpic -Wall -g -Wl,-gc-sections -c -o dbMgmt.o dbMgmt.c dbMgmt.c: In function 'db_mgmt_reload': dbMgmt.c:1729:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode for (int i = 0; i < 2; i++) ^ dbMgmt.c:1729:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
09-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值